First Last Prev Next    No search results available      Search page      Enter new bug
Bug#: 163948
Alias:
Product:
Component:
Status: RESOLVED
Resolution: FIXED
Assigned To: Gentoo's Team for Core System packages <base-system@gentoo.org>
Hardware:
OS:
Version:
Priority:
Severity:
Reporter: Jeff Hansen <sqrammi@hotmail.com>
Add CC:
CC:
URL:
Summary:
Status Whiteboard:
Keywords:

Filename Description Type Creator Created Size Actions
Create a New Attachment (proposed patch, testcase, etc.) View All

Bug 163948 depends on: Show dependency tree
Bug 163948 blocks:
Votes: 0    Show votes for this bug    Vote for this bug

Additional Comments: (this is where you put emerge --info)


Not eligible to see or edit group visibility for this bug.






View Bug Activity   |   Format For Printing   |   XML   |   Clone This Bug


Description:   Opened: 2007-01-26 18:17 0000
When a new struct magic_set is created as the handle to the calling application
(in magic_open), the "file" char * is not NULLified.  This causes unexplained
segfaults in other apps that don't properly have their magic.mgc file created,
i.e. in app-arch/rpm-4.4.6-r3.  The file pointer is some random value, so when
file_magwarn tries to report a missing magic.mgc file, for example, it tries to
print ms->file, which is NULL, and the segfault occurs.

I have submitted a patch that fixes the problem and allows file to properly
tell the user that they are missing a magic.mgc file, instead of just crashing
outright.  We could also just bzero the struct magic_set after it is malloc'ed.


Reproducible: Always

Steps to Reproduce:
1. Try to build an rpm using rpmbuild with the current portage tree.  It
segfaults with no explanation.
2. Or just try to use any app that uses magic_open on an unexisting magic.mgc
file, it will segfault.

Hopefully you won't need to reproduce the problem, though.  It's just bad
practice in file's "magic.c" source code to not initialize the pointer
properly, and then expect it to be set when an error occurs.




--- src/magic.c.orig    2007-01-26 11:00:41.310878002 -0700
+++ src/magic.c 2007-01-26 10:42:51.569916935 -0700
@@ -110,6 +110,7 @@
        ms->haderr = 0;
        ms->error = -1;
        ms->mlist = NULL;
+       ms->file = NULL;
        return ms;
 free3:
        free(ms->o.pbuf);

------- Comment #1 From SpanKY 2007-02-07 04:50:17 0000 -------
looks sane to me ... added to 4.19-r1 and mailed upstream, cheers

First Last Prev Next    No search results available      Search page      Enter new bug