Bug 10762 - RPM core dumps on Solaris 7
Summary: RPM core dumps on Solaris 7
Keywords:
Status: CLOSED WORKSFORME
Alias: None
Product: Red Hat Linux
Classification: Retired
Component: rpm
Version: 6.2
Hardware: sparc
OS: Linux
medium
high
Target Milestone: ---
Assignee: Jeff Johnson
QA Contact:
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2000-04-12 20:19 UTC by Hung Le
Modified: 2008-05-01 15:37 UTC (History)
1 user (show)

Fixed In Version:
Clone Of:
Environment:
Last Closed: 2000-04-13 08:19:20 UTC
Embargoed:


Attachments (Terms of Use)

Description Hung Le 2000-04-12 20:19:30 UTC
When installing an RPM package, the dirInfoCompare function in
lib/depends.c receieved a NULL pointer as parameter 'two' from the bsearch
function.

Some diagnostics from GDB:

(gdb> cont
Breakpoint 1, dirInfoCompare (one=0xffbee068, two=0x0) at depends.c:140
140         const struct dirInfo * a = one;
(gdb) up
#1  0xff1b9b34 in bsearch () from /usr/lib/libc.so.1
(gdb) up
#2  0x430c4 in alFileSatisfiesDepend (al=0x1f1984, keyType=0x0,
    fileName=0x131dfc "/sbin/install-info") at depends.c:773
773         dirMatch = bsearch(&dirNeedle, al->dirs, al->numDirs,
(gdb) print dirNeedle
$22 = {dirName = 0x133038 "/sbin/", dirNameLen = 6, files = 0xffbee0c0,
  numFiles = 403808}
(gdb) print *al
$23 = {list = 0x1f1ae0, index = {index = 0x0, size = 0}, size = 0, alloced
= 5, numDirs = 0, dirs = 0x0}

Comment 1 eric.b.lemings 2000-04-12 21:42:59 UTC
Upon further investigation, it appears that the bsearch function (in Solaris
libc at least) will happily accept a NULL pointer and a zero as the second
(array base) and third (element count) parameters.  (Verify this.)

It all starts with the alSatisfiesDepend function call at depends.c:963 where
the keyType and keyName parameters are NULL pointers.  This gets propagated down
to alFileSatisfiesDepend function which passes the al->dirs and al->numDirs
arguments to bsearch which are NULL and zero.  The dirInfoCompare function then
receieves a NULL pointer from bsearch.

Need to check for NULL and zero before calling bsearch and do the appropriate
thing.  (Eric, Apr 12 2000)

Comment 2 eric.b.lemings 2000-04-12 21:52:59 UTC
Verified.  bsearch will pass the compare function a NULL pointer if given a NULL
base with zero elements.

Comment 3 Jeff Johnson 2000-04-13 08:19:59 UTC
From rpm-list in the last 2 weeks:

--- lib/depends.c.rkorig        Fri Apr  7 11:55:33 2000
+++ lib/depends.c       Fri Apr  7 11:57:32 2000
@@ -761,6 +761,9 @@ alFileSatisfiesDepend(struct availableLi
     struct dirInfo dirNeedle;
     struct dirInfo * dirMatch;

+       if( al->numDirs == 0 )  // Solaris 2.6 bsearch sucks down on this..
+               return NULL;
+
     {  char * chptr = xstrdup(fileName);
        dirName = chptr;
        chptr = strrchr(chptr, '/');


Note You need to log in before you can comment on or make changes to this bug.