Michael Holzheu wrote:
Hi Dave!
This patch fixes the following (minor) problem:
If the directory "/usr/src" does not exist and crash is called without
parameters, it dies with SIGSEGV.
The reason is that the searchdirs buffer is not allocated, if "/usr/src" is
not present. This fix allocates the buffer in any case.
Weird again. In all these years, nobody's ever apparently run
crash on a system without /usr/src?
Queued for next upstream and RHEL5-beta2 releases.
Thanks again,
Dave
---
filesys.c | 14 +++++++++++---
1 file changed, 11 insertions(+), 3 deletions(-)
diff -Naur crash-4.0-3.3/filesys.c crash-4.0-3.3-searchdirs-fix/filesys.c
--- crash-4.0-3.3/filesys.c 2006-09-07 21:00:08.000000000 +0200
+++ crash-4.0-3.3-searchdirs-fix/filesys.c 2006-09-14 14:02:35.000000000 +0200
@@ -315,14 +315,12 @@
for (dp = readdir(dirp); dp != NULL; dp = readdir(dirp))
cnt++;
- if ((searchdirs = (char **)malloc(cnt * sizeof(char *)))
- == NULL) {
+ if ((searchdirs = calloc(cnt, sizeof(char *))) == NULL) {
error(INFO, "/usr/src/ directory list malloc: %s\n",
strerror(errno));
closedir(dirp);
return default_searchdirs;
}
- BZERO(searchdirs, cnt * sizeof(char *));
for (i = 0; i < DEFAULT_SEARCHDIRS; i++)
searchdirs[i] = default_searchdirs[i];
@@ -357,6 +355,16 @@
closedir(dirp);
searchdirs[cnt] = NULL;
+ } else {
+ if ((searchdirs = calloc(cnt, sizeof(char *))) == NULL) {
+ error(INFO, "search directory list malloc: %s\n",
+ strerror(errno));
+ closedir(dirp);
+ return default_searchdirs;
+ }
+ for (i = 0; i < DEFAULT_SEARCHDIRS; i++)
+ searchdirs[i] = default_searchdirs[i];
+ cnt = DEFAULT_SEARCHDIRS;
}
if (redhat_kernel_directory_v1(dirbuf)) {