[Rpm-maint] Check signature rpm segmentation fault
Shakthi Kannan
shakthimaan at gmail.com
Mon May 23 08:49:03 UTC 2011
Hi,
I am trying to check if the signature of a RPM package is valid
(equivalent of rpm --checksig) or not using C. When I run the
following function through a loop (more than 6 times with rpm 4.8.0,
and 13 times with rpm 4.8.1) it causes segmentation fault.
=== BEGIN ===
#include <rpmlib.h>
#include <rpmts.h>
int
rpm_check_signature (char *filename)
{
FD_t fd;
rpmts ts;
rpmVSFlags vsflags = 0;
Header hdr;
rpmRC rc;
rpmReadConfigFiles(NULL, NULL);
fd = Fopen (filename, "r.ufdio");
if (fd == NULL) {
printf ("Error cannot open file\n");
return 1;
}
else {
ts = rpmtsCreate();
(void) rpmtsSetVSFlags (ts, vsflags);
rc = rpmReadPackageFile (ts, fd, filename, &hdr);
ts = rpmtsFree (ts);
Fclose (fd);
return (rc == RPMRC_OK ? 0 : 1);
}
}
=== END ===
I compile it using gcc rpmsig.c -lrpm -lrpmio -I/usr/include/rpm. What
could be missing in the above? Appreciate any inputs in this regard,
Thanks!
SK
--
Shakthi Kannan
http://www.shakthimaan.com
More information about the Rpm-maint
mailing list