]> git.ipfire.org Git - thirdparty/e2fsprogs.git/commitdiff
[COVERITY] Fix segfault bug if the profile directory is empty
authorBrian Behlendorf <behlendorf1@llnl.gov>
Mon, 19 Mar 2007 12:36:45 +0000 (08:36 -0400)
committerTheodore Ts'o <tytso@mit.edu>
Mon, 19 Mar 2007 12:36:45 +0000 (08:36 -0400)
Coverity ID: 5: Forward NULL

Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
e2fsck/ChangeLog
e2fsck/profile.c

index 5abc2e6cbeb3ad8e9295e848f10e273c455cb514..dd0524d4900d46a8a60669ad83f550e6109ca907 100644 (file)
@@ -1,3 +1,9 @@
+2007-03-19  Theodore Tso  <tytso@mit.edu>
+
+       * profile.c (profile_init, get_dirlist): Fix bug where if a
+               profile directory is completely empty, the profile library
+               would segfault.
+
 2006-12-22  Theodore Tso  <tytso@mit.edu>
 
        * unix.c (PRS, main): Use the new {add,remove}_error_table comerr
index e7768a2231e526c1540eae1112bc4fd000c9719c..8030680bf031f421cf4de8ef812da49dbb3bcfe4 100644 (file)
@@ -279,8 +279,10 @@ static errcode_t get_dirlist(const char *dirname, char***ret_array)
                }
                array[num++] = fn;
        }
-       qsort(array, num, sizeof(char *), compstr);
-       array[num++] = 0;
+       if (array) {
+               qsort(array, num, sizeof(char *), compstr);
+               array[num++] = 0;
+       }
        *ret_array = array;
        closedir(dir);
        return 0;
@@ -311,6 +313,8 @@ profile_init(const char **files, profile_t *ret_profile)
            for (fs = files; !PROFILE_LAST_FILESPEC(*fs); fs++) {
                retval = get_dirlist(*fs, &array);
                if (retval == 0) {
+                       if (!array)
+                               continue;
                        for (cpp = array; (cp = *cpp); cpp++) {
                                retval = profile_open_file(cp, &new_file);
                                if (retval == EACCES)