File crash-compressed-booted-kernel.patch of Package crash
---
filesys.c | 37 ++++++++++++++++++++++++++++---------
1 file changed, 28 insertions(+), 9 deletions(-)
--- a/filesys.c
+++ b/filesys.c
@@ -530,6 +530,8 @@ static int
find_booted_kernel(void)
{
char kernel[BUFSIZE];
+ char *kernel_unpacked;
+ char *real_kernel;
char buffer[BUFSIZE];
char **searchdirs;
int i, preferred, wrapped;
@@ -579,16 +581,25 @@ find_booted_kernel(void)
sprintf(kernel, "%s%s", searchdirs[i], dp->d_name);
if (mount_point(kernel) ||
- !file_readable(kernel) ||
- !is_elf_file(kernel))
+ !file_readable(kernel))
continue;
+ if (is_compressed_kernel(kernel, &kernel_unpacked))
+ real_kernel = kernel_unpacked;
+ else {
+ kernel_unpacked = NULL;
+ real_kernel = kernel;
+ }
+
if (CRASHDEBUG(1))
fprintf(fp, "find_booted_kernel: check: %s\n",
kernel);
- found = match_file_string(kernel, kt->proc_version, buffer);
-
+ if (!is_elf_file(real_kernel))
+ continue;
+
+ found = match_file_string(real_kernel, kt->proc_version, buffer);
+
if (found)
break;
}
@@ -599,17 +610,25 @@ find_booted_kernel(void)
build_searchdirs(DESTROY, NULL);
if (found) {
- if ((pc->namelist = (char *)malloc
- (strlen(kernel)+1)) == NULL)
+ if ((pc->namelist_orig = strdup(kernel)) == NULL)
+ error(FATAL, "booted kernel real name malloc: %s\n",
+ strerror(errno));
+ else if ((pc->namelist = strdup(real_kernel)) == NULL)
error(FATAL, "booted kernel name malloc: %s\n",
strerror(errno));
- else {
- strcpy(pc->namelist, kernel);
+ else
if (CRASHDEBUG(1))
fprintf(fp, "find_booted_kernel: found: %s\n",
pc->namelist);
+ if (kernel_unpacked)
+ free(kernel_unpacked);
return TRUE;
- }
+ }
+
+ if (kernel_unpacked) {
+ remove(kernel_unpacked);
+ if (kernel_unpacked)
+ free(kernel_unpacked);
}
error(INFO,