Note: This is a beta release of Red Hat Bugzilla 5.0. The data contained within is a snapshot of the live data so any changes you make will not be reflected in the production Bugzilla. Also email is disabled so feel free to test any aspect of the site that you want. File any problems you find or give feedback here.

Bug 1654

Summary: rpm 2.5.5-5.2: rpmReadPackageHeader gives wrong return value when getting a corrupt package.
Product: [Retired] Red Hat Linux Reporter: bvermeul
Component: rpmAssignee: David Lawrence <dkl>
Status: CLOSED WORKSFORME QA Contact:
Severity: medium Docs Contact:
Priority: medium    
Version: 5.2   
Target Milestone: ---   
Target Release: ---   
Hardware: i386   
OS: Linux   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 1999-03-21 23:44:56 UTC Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:

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>

main()
{
        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
that.