Bug 1654 - rpm 2.5.5-5.2: rpmReadPackageHeader gives wrong return value when getting a corrupt package.
rpm 2.5.5-5.2: rpmReadPackageHeader gives wrong return value when getting a c...
Product: Red Hat Linux
Classification: Retired
Component: rpm (Show other bugs)
i386 Linux
medium Severity medium
: ---
: ---
Assigned To: David Lawrence
Depends On:
  Show dependency treegraph
Reported: 1999-03-21 17:30 EST by bvermeul
Modified: 2008-05-01 11:37 EDT (History)
0 users

See Also:
Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Last Closed: 1999-03-21 18:44:56 EST
Type: ---
Regression: ---
Mount Type: ---
Documentation: ---
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---

Attachments (Terms of Use)

  None (edit)
Description bvermeul 1999-03-21 17:30:14 EST
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 18:03:59 EST
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 18:26:59 EST
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.