FAQ Search Today's Posts Mark Forums Read
» Video Reviews

» Linux Archive

Linux-archive is a website aiming to archive linux email lists and to make them easily accessible for linux users/developers.


» Sponsor

» Partners

» Sponsor

Go Back   Linux Archive > Debian > Debian KDE

 
 
LinkBack Thread Tools
 
Old 09-26-2011, 10:32 PM
"Brian C. Lane"
 
Default Check the return value of get_file_list (#741466)

From: "Brian C. Lane" <bcl@redhat.com>

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@redhat.com
https://www.redhat.com/mailman/listinfo/anaconda-devel-list
 
Old 09-29-2011, 02:34 PM
Chris Lumens
 
Default 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.

Looks good to me.

- Chris

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

Thread Tools




All times are GMT. The time now is 09:04 PM.

VBulletin, Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2007, Crawlability, Inc.
Copyright 2007 - 2008, www.linux-archive.org