[PATCH] Check the return value of get_file_list (#741466)

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

 



From: "Brian C. Lane" <bcl@xxxxxxxxxx>

get_file_list can return a NULL, or a NULL terminated array (which could
have the NULL in the first element) so both conditions need to be
checked when using the result.

NOTE: Untested patch, might be suitable for f16-branch after testing
---
 loader/dirbrowser.c |    7 ++++---
 loader/hdinstall.c  |    2 +-
 loader/nfsinstall.c |    2 +-
 3 files changed, 6 insertions(+), 5 deletions(-)

diff --git a/loader/dirbrowser.c b/loader/dirbrowser.c
index 18d6cdb..e4bc9d4 100644
--- a/loader/dirbrowser.c
+++ b/loader/dirbrowser.c
@@ -53,7 +53,8 @@ static int simpleStringCmp(const void * a, const void * b) {
 
 #define FSTEP 10
 
-/* Return a list of the contents of a directory, non-recursively.
+/* Return a NULL terminated list of the directory contents, non-recursively.
+ * Return a NULL if the directory cannot be opened.
  *
  * dirname    -- The directory to list.
  * filterfunc -- An optional function to use for filtering out the results.
@@ -141,12 +142,12 @@ char * newt_select_file(char * title, char * text, char * dirname,
                          0, 0, 0, 1, 0, 0);
         newtGridSetField(grid, 0, 3, NEWT_GRID_SUBGRID, buttons,
                          0, 0, 0, 0, 0, NEWT_GRID_FLAG_GROWX);
-        
+
         /* if this isn't our topdir, we want to let them go up a dir */
         if (strcmp(topdir, dir))
             newtListboxAppendEntry(listbox, "../", "..");
 
-        for (i = 0; (files[i] != NULL); i++) {
+        for (i = 0; files && (files[i] != NULL); i++) {
             if ((files[i] == NULL) || (strlen(files[i]) == 0)) continue;
             path = malloc(strlen(files[i]) + strlen(dir) + 2);
             sprintf(path, "%s/%s", dir, files[i]);
diff --git a/loader/hdinstall.c b/loader/hdinstall.c
index b336690..a284869 100644
--- a/loader/hdinstall.c
+++ b/loader/hdinstall.c
@@ -278,7 +278,7 @@ int promptForHardDrive(struct loaderData_s *loaderData) {
         }
 
         files = get_file_list(buf, ends_with_iso);
-        if (!files) {
+        if (!files || !files[0] || !strlen(files[0])) {
             newtWinMessage(_("Error"), _("OK"),
                            _("That directory does not contain an installable tree."));
             umount("/mnt/install/isodir");
diff --git a/loader/nfsinstall.c b/loader/nfsinstall.c
index ffaa51b..d29e98a 100644
--- a/loader/nfsinstall.c
+++ b/loader/nfsinstall.c
@@ -190,7 +190,7 @@ static unsigned int isNfsIso(struct loaderData_s *loaderData) {
     }
 
     files = get_file_list("/mnt/install/isodir", ends_with_iso);
-    if (!files) {
+    if (!files || !files[0] || !strlen(files[0])) {
         logMessage(ERROR, "no ISO images present in /mnt/install/isodir");
         goto cleanup2;
     }
-- 
1.7.6

_______________________________________________
Anaconda-devel-list mailing list
Anaconda-devel-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/anaconda-devel-list


[Index of Archives]     [Kickstart]     [Fedora Users]     [Fedora Legacy List]     [Fedora Maintainers]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [Yosemite Photos]     [KDE Users]     [Fedora Tools]
  Powered by Linux