mirror of https://github.com/vitalif/e2fsprogs
[COVERITY] Fix segfault bug if the profile directory is empty
Coverity ID: 5: Forward NULL Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov> Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>bitmap-optimize
parent
e066150a70
commit
12f9195999
|
@ -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
|
||||
|
|
|
@ -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)
|
||||
|
|
Loading…
Reference in New Issue