Bug 59851

Summary: rpmInstallSourcePackage() API seg fault
Product: [Retired] Red Hat Linux Reporter: Melissa Rickman <melissarickman>
Component: rpmAssignee: Jeff Johnson <jbj>
Status: CLOSED WORKSFORME QA Contact:
Severity: medium Docs Contact:
Priority: medium    
Version: 7.2   
Target Milestone: ---   
Target Release: ---   
Hardware: i686   
OS: Linux   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2002-02-15 20:46:31 UTC Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description Melissa Rickman 2002-02-13 21:16:35 UTC
From Bugzilla Helper:
User-Agent: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.0)

Description of problem:
I have created a small C++ exe using the RPM API rpmInstallSourcePackage().  
However, when running the program it seg faults on rpmInstallSourcePackage(). 
It is seg. faulting on the function rpmInstallSourcePackage() in Fileno() 
from /usr/lib/librpmio. The debugger shows me that before it seg faults, the 
program will trace through the lib's rpmInstallSourcePackage(), queryArgCallback
(), rpmInstallSourcePackage(), rpmreadPackageHeader(),readPackageHeaders() and 
finally choke on some Fileno().

my usage of the function is as follows 
... 
rpmInstallSourcePackage(rootDir, fd, specFilePtr,0,0,0) 
where rootDir is a const char * = "to/some/path" 
where fd = Fopen(argv[1]) 
where specFilePtr is a const char **="to/some/path" 
and I substitute null for the rest. 

My program is very simple and only calls two functions from the API.  The Fopen 
and rpmInstallSourcePackage().

Version-Release number of selected component (if applicable):


How reproducible:
Always

Steps to Reproduce:
1.run the program e.g.- # ./instllpkg /development/RPMS/i386/somepkg.rpm
2.
3.
	

Actual Results:  Segmentation fault in the function call in Fileno() 
from /usr/lib/librpmio 4.0.3.so

Expected Results:  The program should execute without segmentation faults, 
install package as specified and write output that it has installed package.

Additional info:

I'm not sure that this is a bug of rpm. Given my lack of knowledge to the rpm 
API I could be giving it bad params or giving it null when it is expecting a 
param.

Comment 1 Jeff Johnson 2002-02-13 21:28:14 UTC
If your program is small, can you attach here? I can probably
tell you what's up even though I'm not a C++ programmer.

Comment 2 Melissa Rickman 2002-02-14 21:40:41 UTC
Jeff, I made some progress with my bug. I ended up using rpmInstall() vs. 
rpmInstallSource(). However, I now get another seg fault that says Error: no db 
path set.  The source is as follows.
#include <rpm/rpmlib.h>

void main()
{
const char * rootdir = "/development"
char * str[]={"/development/RPMS/i386/IM-0.1-1.i386.rpm"};
str[1]='/0';
const char ** temp = const_cast<const char**>(str);
rpmInstall(rootdir,temp,RPMTRANS_FLAG_NONE,INSTALL_HASH,RPMPR0B_FILTER_NONE,0);
}

Comment 3 Jeff Johnson 2002-02-14 21:45:29 UTC
All programs that link against rpmlib need to do
    if (rpmReadConfigFiles(rcfile, NULL))
        exit(EXIT_FAILURE);
early on.

Comment 4 Melissa Rickman 2002-02-15 00:31:39 UTC
ok, something is weird with rpm and its files. My rpmrc file resides 
in /usr/lib. It's visible to ls and when I do rpm --showrc it shows the 
contents of that file.  However, when I use the command # more /usr/lib/rpmrc, 
it says no such file or dir.  This error also happens when I supply this file 
to rpmReadConfigFiles("/usr/lib/rpmrc", NULL).  Another weird thing is that I 
went to view /usr/include/rpmlib.h with the more command and it says that that 
file dn exist, but it does!  I must be doing something wrong????

Comment 5 Jeff Johnson 2002-02-15 20:46:26 UTC
There may be a /usr/lib/rpmrc symlink, but the file(s)
you want/need are
	/usr/lib/rpm/rpmrc
	/usr/lib/rpm/macros
and (possibly)
	/usr/lib/rpm/<arch>-linux/macros
This is what is read by rpmReadConfigFiles(NULL, NULL);
(Yes, NULL will use defaults).

Comment 6 Jeff Johnson 2002-02-24 17:16:46 UTC
If you need more help, please reopen this
bug. Meanwhile I'm gonna close.