Bug 1654 - rpm 2.5.5-5.2: rpmReadPackageHeader gives wrong return value when getting a corrupt package.
Summary: rpm 2.5.5-5.2: rpmReadPackageHeader gives wrong return value when getting a c...
Alias: None
Product: Red Hat Linux
Classification: Retired
Component: rpm
Version: 5.2
Hardware: i386
OS: Linux
Target Milestone: ---
Assignee: David Lawrence
QA Contact:
Depends On:
TreeView+ depends on / blocked
Reported: 1999-03-21 22:30 UTC by bvermeul
Modified: 2008-05-01 15:37 UTC (History)
0 users

Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Clone Of:
Last Closed: 1999-03-21 23:44:56 UTC

Attachments (Terms of Use)

Description bvermeul 1999-03-21 22:30:14 UTC
When rpmReadPackageHeader is called for a corrupt or 0 sized
package (touch bla-1.1-1.i386.rpm does nicely), it doesn't
signal an error. According to the docs (Maximum RPM) it
should return 0 when succesful, 1 when it finds bad magic
numbers, and 2 when another error occurs. When calling
rpmReadPackageHeader on the empty rpm, it returns 0, and it
sets the isSource flag. When headerFree is called on the
resulting Header variable, it segfaults.

Comment 1 Jeff Johnson 1999-03-21 23:03:59 UTC
This program prints "rc 1" using rpm-2.93-1 on sparc Red Hat 5.2.
A perusal of the latest rpm-2.5.x sources indicates that 1 is
what would be expected.

#include <rpm/rpmlib.h>

        FD_t fd;
        Header h;
        int isSource;
        int rc;

        fd = fdOpen("/tmp/foo.src.rpm", 0, 0);
        rc = rpmReadPackageHeader(fd, &h, &isSource, NULL, NULL);
        printf("rc %d\n", rc, isSource);

Comment 2 bvermeul 1999-03-21 23:26:59 UTC
You're absolutely right. I interpreted the code wrong. Sorry 'bout

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