[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

[PATCH f15-branch master] Fixup rindex usage (#678086)



rindex can return a NULL and the strcmp needs to check for .iso
otherwise any file without .iso would cause a segfault
---
 loader/hdinstall.c  |    2 +-
 loader/nfsinstall.c |    2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/loader/hdinstall.c b/loader/hdinstall.c
index c321afb..8f56f98 100644
--- a/loader/hdinstall.c
+++ b/loader/hdinstall.c
@@ -93,7 +93,7 @@ static int ends_with_iso(char *dirname, struct dirent *ent) {
         return 0;
 
     suffix = rindex(ent->d_name, '.');
-    return (!strcmp(suffix, "iso"));
+    return (suffix && !strcmp(suffix, ".iso"));
 }
 
 int loadHdImages(struct loaderData_s *loaderData) {
diff --git a/loader/nfsinstall.c b/loader/nfsinstall.c
index 45260c2..3abdbc0 100644
--- a/loader/nfsinstall.c
+++ b/loader/nfsinstall.c
@@ -178,7 +178,7 @@ static int ends_with_iso(char *dirname, struct dirent *ent) {
         return 0;
 
     suffix = rindex(ent->d_name, '.');
-    return (!strcmp(suffix, ".iso"));
+    return (suffix && !strcmp(suffix, ".iso"));
 }
 
 static unsigned int isNfsIso(struct loaderData_s *loaderData) {
-- 
1.7.4


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]