[PATCH] Fix for some command-line cases an unintended unlink of a file crash didn't create and a leftover temporary

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



When the crash command line includes two filenames where one is a
compressed kernel and the other is a debuginfo file and they appear in
that order then if the uncompressed temporary version of the kernel is
actually larger than the debuginfo then crash will end with an error but
will also unlink the debuginfo file and will not clean up the (intended
temporary) uncompressed copy of the kernel.

This patch at least fixes the unintended unlink and leaving the
temporary present. It doesn't fix the failure to start but that's
because the wrong files are assumed the debuginfo and kernel. The size
case that led to this discovery is probably rare.

The cause is that evidence of a temporary file to unlink is that there
is a value in pc->namelist and pc->namelist_orig (or pc->namelist_debug
and pc->namelist_orig_debug) but when the file size test in
select_namelist() results in the pc->namelist copy to pc->namelist_debug
the _orig is not copied as well so the implied file to unlink is the one
set in pc->namelist (the debuginfo filename now).

The patch causes a populated namelist_orig value to be swapped with
namelist_debug_orig if the namelist value is copied to namelist_debug.

    Signed-off-by: David Mair <dmair@xxxxxxxx>
---
 symbols.c | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/symbols.c b/symbols.c
index 4c6fbf4..e1ed719 100644
--- a/symbols.c
+++ b/symbols.c
@@ -3520,6 +3520,7 @@ int
 select_namelist(char *new)
 {
        struct stat stat1, stat2;
+       char *namecp;

        if (pc->server_namelist) {
                pc->namelist_debug = new;
@@ -3533,6 +3534,12 @@ select_namelist(char *new)

        if (stat1.st_size > stat2.st_size) {
                pc->namelist_debug = pc->namelist;
+               if (pc->namelist_orig)
+               {
+                       namecp = pc->namelist_debug_orig;
+                       pc->namelist_debug_orig = pc->namelist_orig;
+                       pc->namelist_orig = namecp;
+               }
                pc->namelist = new;
        } else if (stat2.st_size > stat1.st_size)
                pc->namelist_debug = new;

--
Crash-utility mailing list
Crash-utility@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/crash-utility




[Index of Archives]     [Fedora Development]     [Fedora Desktop]     [Fedora SELinux]     [Yosemite News]     [KDE Users]     [Fedora Tools]

 

Powered by Linux