diff options
author | Brian C. Lane <bcl@redhat.com> | 2011-09-26 15:25:43 -0700 |
---|---|---|
committer | Brian C. Lane <bcl@redhat.com> | 2011-09-29 08:12:11 -0700 |
commit | a0d3467e67bc66d8c657fd94ff42d7dcd0059c4c (patch) | |
tree | cedeb103f219556fa78aa25eff0f1713246e408d /loader | |
parent | 4384c250266994c2ea4a6b84ff6a823c3cc8e04f (diff) | |
download | anaconda-a0d3467e67bc66d8c657fd94ff42d7dcd0059c4c.tar.gz anaconda-a0d3467e67bc66d8c657fd94ff42d7dcd0059c4c.tar.xz anaconda-a0d3467e67bc66d8c657fd94ff42d7dcd0059c4c.zip |
Check the return value of get_file_list (#741466)
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.
Diffstat (limited to 'loader')
-rw-r--r-- | loader/dirbrowser.c | 7 | ||||
-rw-r--r-- | loader/hdinstall.c | 2 | ||||
-rw-r--r-- | loader/nfsinstall.c | 2 |
3 files changed, 6 insertions, 5 deletions
diff --git a/loader/dirbrowser.c b/loader/dirbrowser.c index 18d6cdb6c..e4bc9d45e 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 b336690c2..a2848695a 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 ffaa51bec..d29e98a9e 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; } |