check for memory leaks (almost all leaks are plugged).
CVS patchset: 3403 CVS date: 1999/10/29 16:06:01
This commit is contained in:
parent
0d0b405c20
commit
1e0138188b
1
CHANGES
1
CHANGES
|
@ -1,6 +1,7 @@
|
|||
3.0.3 -> 3.0.4
|
||||
- use compressed filenames on install side.
|
||||
- start unifying FD types, CFD_t now gone.
|
||||
- check for memory leaks (almost all leaks are plugged).
|
||||
|
||||
3.0.2 -> 3.0.3
|
||||
- add --eval to find result of macro expansion.
|
||||
|
|
13
build.c
13
build.c
|
@ -91,7 +91,6 @@ static int buildForTarget(const char *arg, struct rpmBuildArguments *ba,
|
|||
int test = ba->noBuild;
|
||||
FILE *f;
|
||||
const char * specfile;
|
||||
int res = 0;
|
||||
struct stat statbuf;
|
||||
char buf[BUFSIZ];
|
||||
Spec spec = NULL;
|
||||
|
@ -102,6 +101,7 @@ static int buildForTarget(const char *arg, struct rpmBuildArguments *ba,
|
|||
const char *specDir;
|
||||
const char * tmpSpecFile;
|
||||
char * cmd, *s;
|
||||
int res;
|
||||
|
||||
specDir = rpmGetPath("%{_specdir}", NULL);
|
||||
|
||||
|
@ -158,13 +158,14 @@ static int buildForTarget(const char *arg, struct rpmBuildArguments *ba,
|
|||
|
||||
s = alloca(strlen(specDir) + strlen(cmd) + 5);
|
||||
sprintf(s, "%s/%s", specDir, cmd);
|
||||
res = rename(tmpSpecFile, s);
|
||||
xfree(specDir);
|
||||
xfree(tmpSpecFile);
|
||||
|
||||
if (rename(tmpSpecFile, s)) {
|
||||
if (res) {
|
||||
fprintf(stderr, _("Failed to rename %s to %s: %s\n"),
|
||||
tmpSpecFile, s, strerror(errno));
|
||||
unlink(tmpSpecFile);
|
||||
xfree(specDir);
|
||||
xfree(tmpSpecFile);
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
@ -183,8 +184,6 @@ static int buildForTarget(const char *arg, struct rpmBuildArguments *ba,
|
|||
*cmd = '\0';
|
||||
|
||||
addMacro(NULL, "_sourcedir", NULL, buf, RMIL_TARBALL);
|
||||
xfree(specDir);
|
||||
xfree(tmpSpecFile);
|
||||
specfile = s;
|
||||
} else if (arg[0] == '/') {
|
||||
specfile = arg;
|
||||
|
@ -236,7 +235,7 @@ static int buildForTarget(const char *arg, struct rpmBuildArguments *ba,
|
|||
|
||||
freeSpec(spec);
|
||||
|
||||
return res;
|
||||
return 0;
|
||||
}
|
||||
|
||||
int build(const char *arg, struct rpmBuildArguments *ba, const char *passPhrase,
|
||||
|
|
|
@ -213,19 +213,20 @@ static char *strtokWithQuotes(char *s, char *delim)
|
|||
static void timeCheck(int tc, Header h)
|
||||
{
|
||||
int *mtime;
|
||||
char **file;
|
||||
char **files;
|
||||
int count, x, currentTime;
|
||||
|
||||
headerGetEntry(h, RPMTAG_OLDFILENAMES, NULL, (void **) &file, &count);
|
||||
headerGetEntry(h, RPMTAG_OLDFILENAMES, NULL, (void **) &files, &count);
|
||||
headerGetEntry(h, RPMTAG_FILEMTIMES, NULL, (void **) &mtime, NULL);
|
||||
|
||||
currentTime = time(NULL);
|
||||
|
||||
for (x = 0; x < count; x++) {
|
||||
if (currentTime - mtime[x] > tc) {
|
||||
rpmMessage(RPMMESS_WARNING, _("TIMECHECK failure: %s\n"), file[x]);
|
||||
rpmMessage(RPMMESS_WARNING, _("TIMECHECK failure: %s\n"), files[x]);
|
||||
}
|
||||
}
|
||||
FREE(files);
|
||||
}
|
||||
|
||||
typedef struct VFA {
|
||||
|
@ -591,11 +592,14 @@ static int parseForRegexLang(const char *fileName, /*@out@*/char **lang)
|
|||
|
||||
if (! initialized) {
|
||||
const char *patt = rpmExpand("%{_langpatt}", NULL);
|
||||
int rc = 0;
|
||||
if (!(patt && *patt != '%'))
|
||||
return 1;
|
||||
if (regcomp(&compiledPatt, patt, REG_EXTENDED))
|
||||
return -1;
|
||||
rc = 1;
|
||||
else if (regcomp(&compiledPatt, patt, REG_EXTENDED))
|
||||
rc = -1;
|
||||
xfree(patt);
|
||||
if (rc)
|
||||
return rc;
|
||||
hasRegex = 1;
|
||||
initialized = 1;
|
||||
}
|
||||
|
@ -1170,11 +1174,12 @@ static int processPackageFiles(Spec spec, Package pkg,
|
|||
ffn = rpmGetPath("%{_builddir}/",
|
||||
(spec->buildSubdir ? spec->buildSubdir : "") ,
|
||||
"/", pkg->fileFile, NULL);
|
||||
f = fopen(ffn, "r");
|
||||
xfree(ffn);
|
||||
|
||||
if ((f = fopen(ffn, "r")) == NULL) {
|
||||
if (f == NULL) {
|
||||
rpmError(RPMERR_BADFILENAME,
|
||||
_("Could not open %%files file: %s"), pkg->fileFile);
|
||||
FREE(ffn);
|
||||
return RPMERR_BADFILENAME;
|
||||
}
|
||||
while (fgets(buf, sizeof(buf), f)) {
|
||||
|
@ -1186,12 +1191,11 @@ static int processPackageFiles(Spec spec, Package pkg,
|
|||
appendStringBuf(pkg->fileList, buf);
|
||||
}
|
||||
fclose(f);
|
||||
FREE(ffn);
|
||||
}
|
||||
|
||||
/* Init the file list structure */
|
||||
|
||||
/* XXX spec->buildRoot == NULL, then strdup("") is returned */
|
||||
/* XXX spec->buildRoot == NULL, then xstrdup("") is returned */
|
||||
fl.buildRoot = rpmGetPath(spec->buildRoot, NULL);
|
||||
|
||||
if (headerGetEntry(pkg->header, RPMTAG_DEFAULTPREFIX,
|
||||
|
@ -1354,8 +1358,11 @@ void initSourceHeader(Spec spec)
|
|||
|
||||
spec->sourceHeader = headerNew();
|
||||
/* Only specific tags are added to the source package header */
|
||||
hi = headerInitIterator(spec->packages->header);
|
||||
while (headerNextIterator(hi, &tag, &type, &ptr, &count)) {
|
||||
for (hi = headerInitIterator(spec->packages->header);
|
||||
headerNextIterator(hi, &tag, &type, &ptr, &count);
|
||||
ptr = ((type == RPM_STRING_ARRAY_TYPE || type == RPM_I18NSTRING_TYPE)
|
||||
? xfree(ptr), NULL : NULL))
|
||||
{
|
||||
switch (tag) {
|
||||
case RPMTAG_NAME:
|
||||
case RPMTAG_VERSION:
|
||||
|
@ -1381,18 +1388,16 @@ void initSourceHeader(Spec spec)
|
|||
/* do not copy */
|
||||
break;
|
||||
}
|
||||
if (type == RPM_STRING_ARRAY_TYPE || type == RPM_I18NSTRING_TYPE) {
|
||||
FREE(ptr);
|
||||
}
|
||||
}
|
||||
headerFreeIterator(hi);
|
||||
|
||||
/* Add the build restrictions */
|
||||
hi = headerInitIterator(spec->buildRestrictions);
|
||||
while (headerNextIterator(hi, &tag, &type, &ptr, &count)) {
|
||||
for (hi = headerInitIterator(spec->buildRestrictions);
|
||||
headerNextIterator(hi, &tag, &type, &ptr, &count);
|
||||
ptr = ((type == RPM_STRING_ARRAY_TYPE || type == RPM_I18NSTRING_TYPE)
|
||||
? xfree(ptr), NULL : NULL))
|
||||
{
|
||||
headerAddEntry(spec->sourceHeader, tag, type, ptr, count);
|
||||
if (type == RPM_STRING_ARRAY_TYPE || type == RPM_I18NSTRING_TYPE)
|
||||
FREE(ptr);
|
||||
}
|
||||
headerFreeIterator(hi);
|
||||
|
||||
|
|
|
@ -5,13 +5,22 @@
|
|||
#include "rpmbuild.h"
|
||||
|
||||
static uid_t uids[1024];
|
||||
/*@owned@*/ /*@null@*/ static char *unames[1024];
|
||||
/*@owned@*/ /*@null@*/ static const char *unames[1024];
|
||||
static int uid_used = 0;
|
||||
|
||||
static gid_t gids[1024];
|
||||
/*@owned@*/ /*@null@*/ static char *gnames[1024];
|
||||
/*@owned@*/ /*@null@*/ static const char *gnames[1024];
|
||||
static int gid_used = 0;
|
||||
|
||||
void freeNames(void)
|
||||
{
|
||||
int x;
|
||||
for (x = 0; x < uid_used; x++)
|
||||
xfree(unames[x]);
|
||||
for (x = 0; x < gid_used; x++)
|
||||
xfree(gnames[x]);
|
||||
}
|
||||
|
||||
/*
|
||||
* getUname() takes a uid, gets the username, and creates an entry in the
|
||||
* table to hold a string containing the user name.
|
||||
|
|
|
@ -69,6 +69,7 @@ int packageSources(Spec spec)
|
|||
|
||||
rc = writeRPM(spec->sourceHeader, fn, RPMLEAD_SOURCE,
|
||||
csa, spec->passPhrase, &(spec->cookie));
|
||||
free(csa->cpioFdIn);
|
||||
xfree(fn);
|
||||
}
|
||||
return rc;
|
||||
|
@ -126,6 +127,7 @@ int packageBinaries(Spec spec)
|
|||
char *binRpm, *binDir;
|
||||
binRpm = headerSprintf(pkg->header, binFormat, rpmTagTable,
|
||||
rpmHeaderFormats, &errorString);
|
||||
xfree(binFormat);
|
||||
if (binRpm == NULL) {
|
||||
headerGetEntry(pkg->header, RPMTAG_NAME, NULL,
|
||||
(void **)&name, NULL);
|
||||
|
@ -164,6 +166,7 @@ int packageBinaries(Spec spec)
|
|||
|
||||
rc = writeRPM(pkg->header, fn, RPMLEAD_BINARY,
|
||||
csa, spec->passPhrase, NULL);
|
||||
free(csa->cpioFdIn);
|
||||
xfree(fn);
|
||||
if (rc)
|
||||
return rc;
|
||||
|
|
|
@ -185,15 +185,16 @@ static int checkForDuplicates(Header h, char *name)
|
|||
#if 0 /* XXX harmless, but headerInitIterator() does this anyways */
|
||||
headerSort(h);
|
||||
#endif
|
||||
hi = headerInitIterator(h);
|
||||
lastTag = 0;
|
||||
while (headerNextIterator(hi, &tag, NULL, NULL, NULL)) {
|
||||
if (tag == lastTag) {
|
||||
rpmError(RPMERR_BADSPEC, _("Duplicate %s entries in package: %s"),
|
||||
|
||||
for (hi = headerInitIterator(h), lastTag = 0;
|
||||
headerNextIterator(hi, &tag, NULL, NULL, NULL);
|
||||
lastTag = tag)
|
||||
{
|
||||
if (tag != lastTag)
|
||||
continue;
|
||||
rpmError(RPMERR_BADSPEC, _("Duplicate %s entries in package: %s"),
|
||||
tagName(tag), name);
|
||||
res = 1;
|
||||
}
|
||||
lastTag = tag;
|
||||
res = 1;
|
||||
}
|
||||
headerFreeIterator(hi);
|
||||
|
||||
|
|
|
@ -69,6 +69,7 @@ extern "C" {
|
|||
|
||||
/* from build/names.h */
|
||||
|
||||
void freeNames(void);
|
||||
/*@observer@*/ const char *getUname(uid_t uid);
|
||||
/*@observer@*/ const char *getUnameS(const char *uname);
|
||||
/*@observer@*/ const char *getGname(gid_t gid);
|
||||
|
|
20
lib/cpio.c
20
lib/cpio.c
|
@ -175,15 +175,11 @@ static int getNextHeader(FD_t cfd, /*@out@*/ struct cpioHeader * chPtr)
|
|||
|
||||
GET_NUM_FIELD(physHeader.devMajor, major);
|
||||
GET_NUM_FIELD(physHeader.devMinor, minor);
|
||||
#ifndef __LCLINT__
|
||||
chPtr->dev = makedev(major, minor);
|
||||
#endif
|
||||
chPtr->dev = /*@-shiftsigned@*/ makedev(major, minor) /*@=shiftsigned@*/ ;
|
||||
|
||||
GET_NUM_FIELD(physHeader.rdevMajor, major);
|
||||
GET_NUM_FIELD(physHeader.rdevMinor, minor);
|
||||
#ifndef __LCLINT__
|
||||
chPtr->rdev = makedev(major, minor);
|
||||
#endif
|
||||
chPtr->rdev = /*@-shiftsigned@*/ makedev(major, minor) /*@=shiftsigned@*/ ;
|
||||
|
||||
GET_NUM_FIELD(physHeader.namesize, nameSize);
|
||||
|
||||
|
@ -454,7 +450,7 @@ static void freeLink( /*@only@*/ struct hardLink * li)
|
|||
|
||||
for (i = 0; i < li->nlink; i++) {
|
||||
if (li->files[i] == NULL) continue;
|
||||
free((void *)li->files[i]);
|
||||
/*@-unqualifiedtrans@*/ free(li->files[i]) /*@=unqualifiedtrans@*/ ;
|
||||
li->files[i] = NULL;
|
||||
}
|
||||
free(li->files);
|
||||
|
@ -483,7 +479,7 @@ static int createLinks(struct hardLink * li, /*@out@*/const char ** failedFile)
|
|||
return CPIOERR_LINK_FAILED;
|
||||
}
|
||||
|
||||
free((void *)li->files[i]);
|
||||
/*@-unqualifiedtrans@*/ free(li->files[i]) /*@=unqualifiedtrans@*/ ;
|
||||
li->files[i] = NULL;
|
||||
li->linksLeft--;
|
||||
}
|
||||
|
@ -728,10 +724,10 @@ static int writeFile(FD_t cfd, struct stat sb, struct cpioFileMapping * map,
|
|||
SET_NUM_FIELD(hdr.mtime, sb.st_mtime, buf);
|
||||
SET_NUM_FIELD(hdr.filesize, sb.st_size, buf);
|
||||
|
||||
num = major(sb.st_dev); SET_NUM_FIELD(hdr.devMajor, num, buf);
|
||||
num = minor(sb.st_dev); SET_NUM_FIELD(hdr.devMinor, num, buf);
|
||||
num = major(sb.st_rdev); SET_NUM_FIELD(hdr.rdevMajor, num, buf);
|
||||
num = minor(sb.st_rdev); SET_NUM_FIELD(hdr.rdevMinor, num, buf);
|
||||
num = major((unsigned)sb.st_dev); SET_NUM_FIELD(hdr.devMajor, num, buf);
|
||||
num = minor((unsigned)sb.st_dev); SET_NUM_FIELD(hdr.devMinor, num, buf);
|
||||
num = major((unsigned)sb.st_rdev); SET_NUM_FIELD(hdr.rdevMajor, num, buf);
|
||||
num = minor((unsigned)sb.st_rdev); SET_NUM_FIELD(hdr.rdevMinor, num, buf);
|
||||
|
||||
num = strlen(map->archivePath) + 1; SET_NUM_FIELD(hdr.namesize, num, buf);
|
||||
memcpy(hdr.checksum, "00000000", 8);
|
||||
|
|
|
@ -567,7 +567,7 @@ rpmTransactionSet rpmtransCreateSet(rpmdb db, const char * root)
|
|||
|
||||
rpmdep->orderAlloced = 5;
|
||||
rpmdep->orderCount = 0;
|
||||
rpmdep->order = xcalloc(rpmdep->orderAlloced, sizeof(*rpmdep->order)); /* XXX memory leak */
|
||||
rpmdep->order = xcalloc(rpmdep->orderAlloced, sizeof(*rpmdep->order));
|
||||
|
||||
return rpmdep;
|
||||
}
|
||||
|
@ -710,6 +710,7 @@ void rpmtransFree(rpmTransactionSet rpmdep)
|
|||
alFree(&rpmdep->availablePackages);
|
||||
free(rpmdep->removedPackages);
|
||||
xfree(rpmdep->root);
|
||||
free(rpmdep->order);
|
||||
|
||||
free(rpmdep);
|
||||
}
|
||||
|
@ -1314,7 +1315,7 @@ int rpmdepOrder(rpmTransactionSet rpmdep)
|
|||
qsort(orderList, rpmdep->addedPackages.size, sizeof(*orderList),
|
||||
orderListIndexCmp);
|
||||
|
||||
newOrder = xmalloc(sizeof(*newOrder) * rpmdep->orderCount); /* XXX memory leak */
|
||||
newOrder = xmalloc(sizeof(*newOrder) * rpmdep->orderCount);
|
||||
for (i = 0, newOrderCount = 0; i < orderingCount; i++) {
|
||||
key.alIndex = ordering[i];
|
||||
needle = bsearch(&key, orderList, rpmdep->addedPackages.size,
|
||||
|
|
|
@ -33,9 +33,9 @@ struct fileIndexEntry {
|
|||
} ;
|
||||
|
||||
struct dirInfo {
|
||||
/*@owned@*/ char * dirName; /* strdup'd */
|
||||
/*@owned@*/ char * dirName; /* xstrdup'd */
|
||||
int dirNum;
|
||||
/*@owned@*/ struct fileIndexEntry * files; /* malloc'd */
|
||||
/*@owned@*/ struct fileIndexEntry * files; /* xmalloc'd */
|
||||
int numFiles;
|
||||
} ;
|
||||
|
||||
|
@ -49,7 +49,7 @@ struct availableList {
|
|||
struct availableIndex index;
|
||||
int size, alloced;
|
||||
int numDirs;
|
||||
struct dirInfo * dirs; /* malloc'd */
|
||||
struct dirInfo * dirs; /* xmalloc'd */
|
||||
};
|
||||
|
||||
struct transactionElement {
|
||||
|
|
31
lib/fprint.c
31
lib/fprint.c
|
@ -3,16 +3,20 @@
|
|||
#include <rpmlib.h>
|
||||
#include "fprint.h"
|
||||
|
||||
fingerPrintCache fpCacheCreate(int sizeHint) {
|
||||
fingerPrintCache fpCacheCreate(int sizeHint)
|
||||
{
|
||||
fingerPrintCache fpc;
|
||||
|
||||
fpc = xmalloc(sizeof(*fpc));
|
||||
fpc->ht = htCreate(sizeHint * 2, sizeof(char *), hashFunctionString,
|
||||
fpc->ht = htCreate(sizeHint * 2, sizeof(char *), 1, hashFunctionString,
|
||||
hashEqualityString);
|
||||
return fpc;
|
||||
}
|
||||
|
||||
void fpCacheFree(fingerPrintCache cache) {
|
||||
void fpCacheFree(fingerPrintCache cache)
|
||||
{
|
||||
htFree(cache->ht);
|
||||
free(cache);
|
||||
}
|
||||
|
||||
static const struct fprintCacheEntry_s * cacheContainsDirectory(
|
||||
|
@ -35,7 +39,6 @@ static fingerPrint doLookup(fingerPrintCache cache, const char * dirName,
|
|||
struct stat sb;
|
||||
char * buf;
|
||||
const struct fprintCacheEntry_s * cacheHit;
|
||||
struct fprintCacheEntry_s * newEntry;
|
||||
|
||||
/* assert(*dirName == '/' || !scareMemory); */
|
||||
|
||||
|
@ -72,15 +75,18 @@ static fingerPrint doLookup(fingerPrintCache cache, const char * dirName,
|
|||
if ((cacheHit = cacheContainsDirectory(cache, *buf ? buf : "/"))) {
|
||||
fp.entry = cacheHit;
|
||||
} else if (!stat(*buf ? buf : "/", &sb)) {
|
||||
newEntry = xmalloc(sizeof(*fp.entry));
|
||||
size_t nb = sizeof(*fp.entry) + (*buf ? strlen(buf) : 1) + 1;
|
||||
char * dn = xmalloc(nb);
|
||||
struct fprintCacheEntry_s * newEntry = (void *)dn;
|
||||
dn += sizeof(*newEntry);
|
||||
strcpy(dn, (*buf ? buf : "/"));
|
||||
newEntry->ino = sb.st_ino;
|
||||
newEntry->dev = sb.st_dev;
|
||||
newEntry->isFake = 0;
|
||||
newEntry->dirName = xstrdup(*buf ? buf : "/");
|
||||
newEntry->dirName = dn;
|
||||
fp.entry = newEntry;
|
||||
|
||||
/* XXX FIXME: memory leak */
|
||||
htAddEntry(cache->ht, xstrdup(*buf ? buf : "/"), fp.entry);
|
||||
htAddEntry(cache->ht, dn, fp.entry);
|
||||
}
|
||||
|
||||
if (fp.entry) {
|
||||
|
@ -112,7 +118,8 @@ static fingerPrint doLookup(fingerPrintCache cache, const char * dirName,
|
|||
}
|
||||
|
||||
fingerPrint fpLookup(fingerPrintCache cache, const char * fullName,
|
||||
int scareMemory) {
|
||||
int scareMemory)
|
||||
{
|
||||
char *dn = strcpy(alloca(strlen(fullName)+1), fullName);
|
||||
char *bn = strrchr(dn, '/');
|
||||
|
||||
|
@ -152,7 +159,8 @@ int fpEqual(const void * key1, const void * key2)
|
|||
|
||||
void fpLookupList(fingerPrintCache cache, const char ** dirNames,
|
||||
const char ** baseNames, const int * dirIndexes,
|
||||
int fileCount, fingerPrint * fpList) {
|
||||
int fileCount, fingerPrint * fpList)
|
||||
{
|
||||
int i;
|
||||
|
||||
for (i = 0; i < fileCount; i++) {
|
||||
|
@ -169,7 +177,8 @@ void fpLookupList(fingerPrintCache cache, const char ** dirNames,
|
|||
}
|
||||
}
|
||||
|
||||
void fpLookupHeader(fingerPrintCache cache, Header h, fingerPrint * fpList) {
|
||||
void fpLookupHeader(fingerPrintCache cache, Header h, fingerPrint * fpList)
|
||||
{
|
||||
int fileCount;
|
||||
const char ** baseNames, ** dirNames;
|
||||
int_32 * dirIndexes;
|
||||
|
|
62
lib/fs.c
62
lib/fs.c
|
@ -12,6 +12,22 @@ struct fsinfo {
|
|||
/*@only@*/ /*@null@*/ static const char ** fsnames = NULL;
|
||||
static int numFilesystems = 0;
|
||||
|
||||
void freeFilesystems(void)
|
||||
{
|
||||
if (filesystems) {
|
||||
int i;
|
||||
for (i = 0; i < numFilesystems; i++)
|
||||
xfree(filesystems[i].mntPoint);
|
||||
free(filesystems);
|
||||
filesystems = NULL;
|
||||
}
|
||||
if (fsnames) {
|
||||
free(fsnames);
|
||||
fsnames = NULL;
|
||||
}
|
||||
numFilesystems = 0;
|
||||
}
|
||||
|
||||
#if HAVE_MNTCTL
|
||||
|
||||
/* modeled after sample code from Till Bubeck */
|
||||
|
@ -75,12 +91,8 @@ static int getFilesystemList(void)
|
|||
rpmError(RPMERR_STAT, _("failed to stat %s: %s"), fsnames[i],
|
||||
strerror(errno));
|
||||
|
||||
free(filesystems);
|
||||
filesystems = NULL;
|
||||
for (i = 0; i < num; i++)
|
||||
free(fsnames[i]);
|
||||
free(fsnames);
|
||||
fsnames = NULL;
|
||||
freeFileSystems();
|
||||
return 1;
|
||||
}
|
||||
|
||||
filesystems[i].dev = sb.st_dev;
|
||||
|
@ -94,11 +106,12 @@ static int getFilesystemList(void)
|
|||
|
||||
return 0;
|
||||
}
|
||||
#else
|
||||
|
||||
#else /* HAVE_MNTCTL */
|
||||
|
||||
static int getFilesystemList(void)
|
||||
{
|
||||
int numAlloced = 10;
|
||||
int num = 0;
|
||||
struct stat sb;
|
||||
int i;
|
||||
char * mntdir;
|
||||
|
@ -126,6 +139,7 @@ static int getFilesystemList(void)
|
|||
|
||||
filesystems = xcalloc((numAlloced + 1), sizeof(*filesystems)); /* XXX memory leak */
|
||||
|
||||
numFilesystems = 0;
|
||||
while (1) {
|
||||
# if GETMNTENT_ONE
|
||||
/* this is Linux */
|
||||
|
@ -146,23 +160,19 @@ static int getFilesystemList(void)
|
|||
rpmError(RPMERR_STAT, "failed to stat %s: %s", mntdir,
|
||||
strerror(errno));
|
||||
|
||||
for (i = 0; i < num; i++)
|
||||
xfree(filesystems[i].mntPoint);
|
||||
free(filesystems);
|
||||
|
||||
filesystems = NULL;
|
||||
freeFilesystems();
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (num == numAlloced) {
|
||||
numFilesystems++;
|
||||
if ((numFilesystems + 1) == numAlloced) {
|
||||
numAlloced += 10;
|
||||
filesystems = xrealloc(filesystems,
|
||||
sizeof(*filesystems) * (numAlloced + 1));
|
||||
}
|
||||
|
||||
filesystems[num].dev = sb.st_dev;
|
||||
filesystems[num].mntPoint = xstrdup(mntdir); /* XXX memory leak */
|
||||
num++;
|
||||
filesystems[numFilesystems-1].dev = sb.st_dev;
|
||||
filesystems[numFilesystems-1].mntPoint = xstrdup(mntdir);
|
||||
}
|
||||
|
||||
# if GETMNTENT_ONE || GETMNTENT_TWO
|
||||
|
@ -171,19 +181,17 @@ static int getFilesystemList(void)
|
|||
free(mounts);
|
||||
# endif
|
||||
|
||||
filesystems[num].dev = 0;
|
||||
filesystems[num].mntPoint = NULL;
|
||||
filesystems[numFilesystems].dev = 0;
|
||||
filesystems[numFilesystems].mntPoint = NULL;
|
||||
|
||||
fsnames = xcalloc((num + 1), sizeof(*fsnames)); /* XXX memory leak */
|
||||
for (i = 0; i < num; i++)
|
||||
fsnames = xcalloc((numFilesystems + 1), sizeof(*fsnames));
|
||||
for (i = 0; i < numFilesystems; i++)
|
||||
fsnames[i] = filesystems[i].mntPoint;
|
||||
fsnames[num] = NULL;
|
||||
|
||||
numFilesystems = num;
|
||||
fsnames[numFilesystems] = NULL;
|
||||
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
#endif /* HAVE_MNTCTL */
|
||||
|
||||
int rpmGetFilesystemList(const char *** listptr, int * num)
|
||||
{
|
||||
|
@ -217,7 +225,7 @@ int rpmGetFilesystemUsage(const char ** fileList, int_32 * fssizes, int numFiles
|
|||
|
||||
usages = xcalloc(numFilesystems, sizeof(usages));
|
||||
|
||||
sourceDir = rpmGetPath("", "/%{_sourcedir}", NULL);
|
||||
sourceDir = rpmGetPath("%{_sourcedir}", NULL);
|
||||
|
||||
maxLen = strlen(sourceDir);
|
||||
for (i = 0; i < numFiles; i++) {
|
||||
|
@ -252,6 +260,7 @@ int rpmGetFilesystemUsage(const char ** fileList, int_32 * fssizes, int numFiles
|
|||
if (errno != ENOENT) {
|
||||
rpmError(RPMERR_STAT, _("failed to stat %s: %s"), buf,
|
||||
strerror(errno));
|
||||
xfree(sourceDir);
|
||||
free(usages);
|
||||
return 1;
|
||||
}
|
||||
|
@ -272,6 +281,7 @@ int rpmGetFilesystemUsage(const char ** fileList, int_32 * fssizes, int numFiles
|
|||
if (j == numFilesystems) {
|
||||
rpmError(RPMERR_BADDEV,
|
||||
_("file %s is on an unknown device"), buf);
|
||||
xfree(sourceDir);
|
||||
free(usages);
|
||||
return 1;
|
||||
}
|
||||
|
|
11
lib/hash.c
11
lib/hash.c
|
@ -13,6 +13,7 @@ struct hashBucket {
|
|||
struct hashTable_s {
|
||||
int numBuckets;
|
||||
int keySize;
|
||||
int freeData;
|
||||
struct hashBucket ** buckets;
|
||||
hashFunctionType fn;
|
||||
hashEqualityType eq;
|
||||
|
@ -56,7 +57,7 @@ unsigned int hashFunctionString(const void * string)
|
|||
return ((((unsigned)len) << 16) + (((unsigned)sum) << 8) + xorValue);
|
||||
}
|
||||
|
||||
hashTable htCreate(int numBuckets, int keySize, hashFunctionType fn,
|
||||
hashTable htCreate(int numBuckets, int keySize, int freeData, hashFunctionType fn,
|
||||
hashEqualityType eq)
|
||||
{
|
||||
hashTable ht;
|
||||
|
@ -65,6 +66,7 @@ hashTable htCreate(int numBuckets, int keySize, hashFunctionType fn,
|
|||
ht->numBuckets = numBuckets;
|
||||
ht->buckets = xcalloc(numBuckets, sizeof(*ht->buckets));
|
||||
ht->keySize = keySize;
|
||||
ht->freeData = freeData;
|
||||
ht->fn = fn;
|
||||
ht->eq = eq;
|
||||
|
||||
|
@ -103,15 +105,18 @@ void htAddEntry(hashTable ht, const void * key, const void * data)
|
|||
|
||||
void htFree(hashTable ht)
|
||||
{
|
||||
int i;
|
||||
struct hashBucket * b, * n;
|
||||
int i;
|
||||
|
||||
for (i = 0; i < ht->numBuckets; i++) {
|
||||
b = ht->buckets[i];
|
||||
if (ht->keySize && b) xfree(b->key);
|
||||
while (b) {
|
||||
n = b->next;
|
||||
if (b->data) xfree(b->data);
|
||||
if (b->data) {
|
||||
if (ht->freeData && *b->data) xfree(*b->data);
|
||||
xfree(b->data);
|
||||
}
|
||||
free(b);
|
||||
b = n;
|
||||
}
|
||||
|
|
|
@ -15,8 +15,8 @@ int hashEqualityString(const void * key1, const void * key2);
|
|||
|
||||
/* if keySize > 0, the key is duplicated within the table (which costs
|
||||
memory, but may be usefull anyway */
|
||||
hashTable htCreate(int numBuckets, int keySize, hashFunctionType fn,
|
||||
hashEqualityType eq);
|
||||
hashTable htCreate(int numBuckets, int keySize, int freeData,
|
||||
hashFunctionType fn, hashEqualityType eq);
|
||||
void htAddEntry(hashTable ht, const void * key, const void * data);
|
||||
void htFree( /*@only@*/ hashTable ht);
|
||||
/* returns 0 on success, 1 if the item is not found. tableKey may be NULL */
|
||||
|
|
|
@ -949,8 +949,8 @@ headerFindI18NString(Header h, struct indexEntry *entry)
|
|||
return entry->data;
|
||||
}
|
||||
|
||||
static int intGetEntry(Header h, int_32 tag, /*@out@*/int_32 *type, /*@out@*/void **p, /*@out@*/int_32 *c,
|
||||
int minMem)
|
||||
static int intGetEntry(Header h, int_32 tag, /*@out@*/ int_32 *type,
|
||||
/*@out@*/ void **p, /*@out@*/ int_32 *c, int minMem)
|
||||
{
|
||||
struct indexEntry * entry;
|
||||
char * chptr;
|
||||
|
|
|
@ -139,6 +139,7 @@ int headerAddOrAppendEntry(Header h, int_32 tag, int_32 type,
|
|||
entry is present). */
|
||||
int headerGetEntry(Header h, int_32 tag, /*@out@*/ int_32 *type,
|
||||
/*@out@*/ void **p, /*@out@*/int_32 *c);
|
||||
|
||||
/* This gets an entry, and uses as little extra RAM as possible to represent
|
||||
it (this is only an issue for RPM_STRING_ARRAY_TYPE. */
|
||||
int headerGetEntryMinMemory(Header h, int_32 tag, int_32 *type,
|
||||
|
|
|
@ -1399,7 +1399,7 @@ rpmExpand(const char *arg, ...)
|
|||
}
|
||||
va_end(ap);
|
||||
expandMacros(NULL, NULL, buf, sizeof(buf));
|
||||
return xstrdup(buf); /* XXX build memory leaks */
|
||||
return xstrdup(buf);
|
||||
}
|
||||
|
||||
int
|
||||
|
|
27
lib/misc.c
27
lib/misc.c
|
@ -406,10 +406,10 @@ char * currentDirectory(void) {
|
|||
}
|
||||
|
||||
void compressFilelist(Header h) {
|
||||
char ** files;
|
||||
char ** dirList;
|
||||
const char ** files;
|
||||
const char ** dirList;
|
||||
int * compDirList;
|
||||
char ** baseNames;
|
||||
const char ** baseNames;
|
||||
int fileCount;
|
||||
int i;
|
||||
char * tail;
|
||||
|
@ -427,7 +427,8 @@ void compressFilelist(Header h) {
|
|||
|
||||
if (files[0][0] != '/') {
|
||||
/* HACK. Source RPM, so just do things differently */
|
||||
return ;
|
||||
free(files);
|
||||
return;
|
||||
}
|
||||
|
||||
dirList = alloca(sizeof(*dirList) * fileCount); /* worst case */
|
||||
|
@ -435,14 +436,14 @@ void compressFilelist(Header h) {
|
|||
compDirList = alloca(sizeof(*compDirList) * fileCount);
|
||||
|
||||
for (i = 0; i < fileCount; i++) {
|
||||
tail = strrchr(files[i], '/') + 1;
|
||||
char *tail = strrchr(files[i], '/') + 1;
|
||||
|
||||
if (lastDir < 0 || (lastLen != (tail - files[i])) ||
|
||||
strncmp(dirList[lastDir], files[i], tail - files[i])) {
|
||||
lastDir++;
|
||||
dirList[lastDir] = alloca(tail - files[i] + 1);
|
||||
memcpy(dirList[lastDir], files[i], tail - files[i]);
|
||||
dirList[lastDir][tail - files[i]] = '\0';
|
||||
char *s = alloca(tail - files[i] + 1);
|
||||
memcpy(s, files[i], tail - files[i]);
|
||||
s[tail - files[i]] = '\0';
|
||||
dirList[++lastDir] = s;
|
||||
lastLen = tail - files[i];
|
||||
}
|
||||
|
||||
|
@ -468,10 +469,10 @@ static void doBuildFileList(Header h, /*@out@*/ char *** fileListPtr,
|
|||
/*@out@*/ int * fileCountPtr, int baseNameTag,
|
||||
int dirListTag, int dirIndexesTag) {
|
||||
int * dirList;
|
||||
char ** dirs;
|
||||
char ** tails;
|
||||
const char ** dirs;
|
||||
const char ** tails;
|
||||
int count;
|
||||
char ** fileList;
|
||||
const char ** fileList;
|
||||
int size;
|
||||
char * data;
|
||||
int i;
|
||||
|
@ -503,6 +504,8 @@ static void doBuildFileList(Header h, /*@out@*/ char *** fileListPtr,
|
|||
|
||||
*fileListPtr = fileList;
|
||||
*fileCountPtr = count;
|
||||
free(tails);
|
||||
free(dirs);
|
||||
}
|
||||
|
||||
void buildFileList(Header h, char *** fileListPtr, int * fileCountPtr) {
|
||||
|
|
|
@ -20,9 +20,10 @@ int rpmdbRebuild(const char * rootdir)
|
|||
rpmMessage(RPMMESS_DEBUG, _("rebuilding database in rootdir %s\n"), rootdir);
|
||||
|
||||
dbpath = rpmGetPath("%{_dbpath}", NULL);
|
||||
if (!dbpath || dbpath[0] == '%') {
|
||||
if (!(dbpath && dbpath[0] != '%')) {
|
||||
rpmMessage(RPMMESS_DEBUG, _("no dbpath has been set"));
|
||||
return 1;
|
||||
rc = 1;
|
||||
goto exit;
|
||||
}
|
||||
|
||||
sprintf(tfn, "rebuilddb.%d", (int) getpid());
|
||||
|
|
|
@ -276,8 +276,11 @@ int rpmCheckSig(int flags, const char **argv)
|
|||
untrustedKeys[0] = '\0';
|
||||
sprintf(buffer, "%s:%c", rpm, (rpmIsVerbose() ? '\n' : ' ') );
|
||||
|
||||
sigIter = headerInitIterator(sig);
|
||||
while (headerNextIterator(sigIter, &tag, &type, &ptr, &count)) {
|
||||
for (sigIter = headerInitIterator(sig);
|
||||
headerNextIterator(sigIter, &tag, &type, &ptr, &count);
|
||||
ptr = ((type == RPM_STRING_ARRAY_TYPE || type == RPM_I18NSTRING_TYPE)
|
||||
? xfree(ptr), NULL : NULL))
|
||||
{
|
||||
switch (tag) {
|
||||
case RPMSIGTAG_PGP5: /* XXX legacy */
|
||||
case RPMSIGTAG_PGP:
|
||||
|
|
35
lib/rpmdb.c
35
lib/rpmdb.c
|
@ -61,16 +61,13 @@ static void unblockSignals(void)
|
|||
|
||||
int rpmdbOpenForTraversal(const char * prefix, rpmdb * rpmdbp)
|
||||
{
|
||||
const char * dbpath;
|
||||
const char * dbpath = rpmGetPath("%{_dbpath}", NULL);
|
||||
int rc = 0;
|
||||
|
||||
dbpath = rpmGetPath("%{_dbpath}", NULL);
|
||||
if (dbpath == NULL || dbpath[0] == '%') {
|
||||
if (!(dbpath && dbpath[0] != '%')) {
|
||||
rpmMessage(RPMMESS_DEBUG, _("no dbpath has been set"));
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (openDatabase(prefix, dbpath, rpmdbp, O_RDONLY, 0644,
|
||||
rc = 1;
|
||||
} else if (openDatabase(prefix, dbpath, rpmdbp, O_RDONLY, 0644,
|
||||
RPMDB_FLAG_MINIMAL)) {
|
||||
rc = 1;
|
||||
}
|
||||
|
@ -80,33 +77,29 @@ int rpmdbOpenForTraversal(const char * prefix, rpmdb * rpmdbp)
|
|||
|
||||
int rpmdbOpen (const char * prefix, rpmdb *rpmdbp, int mode, int perms)
|
||||
{
|
||||
const char * dbpath;
|
||||
const char * dbpath = rpmGetPath("%{_dbpath}", NULL);
|
||||
int rc;
|
||||
|
||||
dbpath = rpmGetPath("%{_dbpath}", NULL);
|
||||
if (dbpath == NULL || dbpath[0] == '%') {
|
||||
if (!(dbpath && dbpath[0] != '%')) {
|
||||
rpmMessage(RPMMESS_DEBUG, _("no dbpath has been set"));
|
||||
return 1;
|
||||
}
|
||||
|
||||
rc = openDatabase(prefix, dbpath, rpmdbp, mode, perms, 0);
|
||||
rc = 1;
|
||||
} else
|
||||
rc = openDatabase(prefix, dbpath, rpmdbp, mode, perms, 0);
|
||||
xfree(dbpath);
|
||||
return rc;
|
||||
}
|
||||
|
||||
int rpmdbInit (const char * prefix, int perms)
|
||||
{
|
||||
const char * dbpath = rpmGetPath("%{_dbpath}", NULL);
|
||||
rpmdb db;
|
||||
const char * dbpath;
|
||||
int rc;
|
||||
|
||||
dbpath = rpmGetPath("%{_dbpath}", NULL);
|
||||
if (dbpath == NULL || dbpath[0] == '%') {
|
||||
if (!(dbpath && dbpath[0] != '%')) {
|
||||
rpmMessage(RPMMESS_DEBUG, _("no dbpath has been set"));
|
||||
return 1;
|
||||
}
|
||||
|
||||
rc = openDatabase(prefix, dbpath, &db, O_CREAT | O_RDWR, perms,
|
||||
rc = 1;
|
||||
} else
|
||||
rc = openDatabase(prefix, dbpath, &db, O_CREAT | O_RDWR, perms,
|
||||
RPMDB_FLAG_JUSTCHECK);
|
||||
xfree(dbpath);
|
||||
return rc;
|
||||
|
|
|
@ -265,7 +265,7 @@ extern const struct headerSprintfExtension rpmHeaderFormats[];
|
|||
|
||||
#define xfree(_p) free((void *)_p)
|
||||
|
||||
char * rpmGetVar(int var);
|
||||
const char * rpmGetVar(int var);
|
||||
void rpmSetVar(int var, const char *val);
|
||||
|
||||
/** rpmrc.c **/
|
||||
|
@ -650,6 +650,7 @@ void rpmFreeSignature(Header h);
|
|||
int rpmVerifySignature(const char *file, int_32 sigTag, void *sig, int count,
|
||||
char *result);
|
||||
|
||||
void freeFilesystems(void);
|
||||
int rpmGetFilesystemList( /*@out@*/ const char *** listptr, /*@out@*/int * num);
|
||||
int rpmGetFilesystemUsage(const char ** filelist, int_32 * fssizes,
|
||||
int numFiles, /*@out@*/ uint_32 ** usagesPtr, int flags);
|
||||
|
|
89
lib/rpmrc.c
89
lib/rpmrc.c
|
@ -38,14 +38,14 @@ struct machEquivTable {
|
|||
};
|
||||
|
||||
struct rpmvarValue {
|
||||
char * value;
|
||||
const char * value;
|
||||
/* eventually, this arch will be replaced with a generic condition */
|
||||
char * arch;
|
||||
const char * arch;
|
||||
struct rpmvarValue * next;
|
||||
};
|
||||
|
||||
struct rpmOption {
|
||||
char * name;
|
||||
const char * name;
|
||||
int var;
|
||||
int archSpecific, required, macroize, localize;
|
||||
struct rpmOptionValue * value;
|
||||
|
@ -104,45 +104,10 @@ static int currTables[2] = { RPM_MACHTABLE_INSTOS, RPM_MACHTABLE_INSTARCH };
|
|||
static struct rpmvarValue values[RPMVAR_NUM];
|
||||
|
||||
/* prototypes */
|
||||
static void defaultMachine(/*@out@*/ const char ** arch, /*@out@*/ const char ** os);
|
||||
static int doReadRC(FD_t fd, const char * filename);
|
||||
static int optionCompare(const void * a, const void * b);
|
||||
static int addCanon(struct canonEntry **table, int *tableLen, char *line,
|
||||
const char *fn, int lineNum);
|
||||
static int addDefault(struct defaultEntry **table, int *tableLen, char *line,
|
||||
const char *fn, int lineNum);
|
||||
static void freeRpmVar(struct rpmvarValue * orig);
|
||||
static void rpmSetVarArch(int var, const char * val, const char * arch);
|
||||
static struct canonEntry *lookupInCanonTable(char *name,
|
||||
struct canonEntry *table,
|
||||
int tableLen);
|
||||
static const char *lookupInDefaultTable(const char *name,
|
||||
struct defaultEntry *table,
|
||||
int tableLen);
|
||||
|
||||
static void setVarDefault(int var, const char *macroname, const char *val, const char *body);
|
||||
static void setPathDefault(int var, const char *macroname, const char *subdir);
|
||||
static void setDefaults(void);
|
||||
|
||||
static void rebuildCompatTables(int type, const char *name);
|
||||
|
||||
/* compatiblity tables */
|
||||
static int machCompatCacheAdd(char * name, const char * fn, int linenum,
|
||||
struct machCache * cache);
|
||||
static struct machCacheEntry * machCacheFindEntry(struct machCache * cache,
|
||||
const char * key);
|
||||
static struct machEquivInfo * machEquivSearch(
|
||||
struct machEquivTable * table, const char * name);
|
||||
static void machAddEquiv(struct machEquivTable * table, const char * name,
|
||||
int distance);
|
||||
static void machCacheEntryVisit(struct machCache * cache,
|
||||
struct machEquivTable * table,
|
||||
const char * name,
|
||||
int distance);
|
||||
static void machFindEquivs(struct machCache * cache,
|
||||
struct machEquivTable * table,
|
||||
const char * key);
|
||||
|
||||
static int optionCompare(const void * a, const void * b) {
|
||||
return strcasecmp(((struct rpmOption *) a)->name,
|
||||
((struct rpmOption *) b)->name);
|
||||
|
@ -259,9 +224,9 @@ static void machAddEquiv(struct machEquivTable * table, const char * name,
|
|||
table->list = xrealloc(table->list, (table->count + 1)
|
||||
* sizeof(*table->list));
|
||||
else
|
||||
table->list = xmalloc(sizeof(*table->list)); /* XXX memory leak */
|
||||
table->list = xmalloc(sizeof(*table->list));
|
||||
|
||||
table->list[table->count].name = xstrdup(name); /* XXX memory leak */
|
||||
table->list[table->count].name = xstrdup(name);
|
||||
table->list[table->count++].score = distance;
|
||||
}
|
||||
}
|
||||
|
@ -297,7 +262,13 @@ static void machFindEquivs(struct machCache * cache,
|
|||
for (i = 0; i < cache->size; i++)
|
||||
cache->cache[i].visited = 0;
|
||||
|
||||
while (table->count > 0) {
|
||||
xfree(table->list[--table->count].name);
|
||||
table->list[table->count].name = NULL;
|
||||
}
|
||||
table->count = 0;
|
||||
if (table->list) xfree(table->list);
|
||||
table->list = NULL;
|
||||
|
||||
/* We have a general graph built using strings instead of pointers.
|
||||
Yuck. We have to start at a point at traverse it, remembering how
|
||||
|
@ -588,15 +559,21 @@ int rpmReadRC(const char * rcfiles)
|
|||
|
||||
rpmSetMachine(NULL, NULL); /* XXX WTFO? Why bother? */
|
||||
|
||||
if ((r = rpmGetVar(RPMVAR_MACROFILES)) != NULL)
|
||||
initMacros(NULL, r);
|
||||
{ const char *macrofiles;
|
||||
if ((macrofiles = rpmGetVar(RPMVAR_MACROFILES)) != NULL) {
|
||||
macrofiles = strdup(macrofiles);
|
||||
initMacros(NULL, macrofiles);
|
||||
xfree(macrofiles);
|
||||
}
|
||||
}
|
||||
|
||||
return rc;
|
||||
}
|
||||
|
||||
static int doReadRC(FD_t fd, const char * filename)
|
||||
{
|
||||
char *s, *se, *next;
|
||||
const char *s;
|
||||
char *se, *next;
|
||||
int linenum = 0;
|
||||
struct rpmOption searchOption, * option;
|
||||
int rc;
|
||||
|
@ -616,7 +593,7 @@ static int doReadRC(FD_t fd, const char * filename)
|
|||
while (*next) {
|
||||
linenum++;
|
||||
|
||||
se = s = next;
|
||||
s = se = next;
|
||||
while (*se && *se != '\n') se++;
|
||||
if (*se) *se++ = '\0';
|
||||
next = se;
|
||||
|
@ -626,7 +603,7 @@ static int doReadRC(FD_t fd, const char * filename)
|
|||
/* we used to allow comments to begin anywhere, but not anymore */
|
||||
if (*s == '#' || *s == '\0') continue;
|
||||
|
||||
se = s;
|
||||
se = (char *)s;
|
||||
while (*se && !isspace(*se) && *se != ':') se++;
|
||||
|
||||
if (isspace(*se)) {
|
||||
|
@ -761,7 +738,7 @@ static int doReadRC(FD_t fd, const char * filename)
|
|||
}
|
||||
|
||||
if (i < RPM_MACHTABLE_COUNT) {
|
||||
char *rest = s + strlen(tables[i].key);
|
||||
const char *rest = s + strlen(tables[i].key);
|
||||
if (*rest == '_') rest++;
|
||||
|
||||
if (!strcmp(rest, "compat")) {
|
||||
|
@ -966,7 +943,7 @@ static void defaultMachine(const char ** arch, const char ** os) {
|
|||
if (os) *os = un.sysname;
|
||||
}
|
||||
|
||||
static char * rpmGetVarArch(int var, char * arch) {
|
||||
static const char * rpmGetVarArch(int var, char * arch) {
|
||||
struct rpmvarValue * next;
|
||||
|
||||
if (!arch) arch = current[ARCH];
|
||||
|
@ -985,7 +962,7 @@ static char * rpmGetVarArch(int var, char * arch) {
|
|||
return next ? next->value : NULL;
|
||||
}
|
||||
|
||||
char *rpmGetVar(int var)
|
||||
const char *rpmGetVar(int var)
|
||||
{
|
||||
return rpmGetVarArch(var, NULL);
|
||||
}
|
||||
|
@ -997,11 +974,11 @@ static void freeRpmVar(struct rpmvarValue * orig) {
|
|||
while (var) {
|
||||
next = var->next;
|
||||
if (var->arch) {
|
||||
free(var->arch);
|
||||
xfree(var->arch);
|
||||
var->arch = NULL;
|
||||
}
|
||||
if (var->value) {
|
||||
free(var->value);
|
||||
xfree(var->value);
|
||||
var->value = NULL;
|
||||
}
|
||||
|
||||
|
@ -1032,16 +1009,18 @@ static void rpmSetVarArch(int var, const char * val, const char * arch) {
|
|||
}
|
||||
|
||||
if (next->arch && arch && !strcmp(next->arch, arch)) {
|
||||
if (next->value) free(next->value);
|
||||
if (next->arch) free(next->arch);
|
||||
if (next->value) xfree(next->value);
|
||||
if (next->arch) xfree(next->arch);
|
||||
} else if (next->arch || arch) {
|
||||
next->next = xmalloc(sizeof(*next->next));
|
||||
next = next->next;
|
||||
next->value = NULL;
|
||||
next->arch = NULL;
|
||||
next->next = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
next->value = xstrdup(val);
|
||||
next->value = xstrdup(val); /* XXX memory leak, hard to plug */
|
||||
next->arch = (arch ? xstrdup(arch) : NULL);
|
||||
}
|
||||
|
||||
|
@ -1236,7 +1215,7 @@ void rpmRebuildTargetVars(const char **buildtarget, const char ** canontarget)
|
|||
/*
|
||||
* XXX Make sure that per-arch optflags is initialized correctly.
|
||||
*/
|
||||
{ char *optflags = rpmGetVarArch(RPMVAR_OPTFLAGS, ca);
|
||||
{ const char *optflags = rpmGetVarArch(RPMVAR_OPTFLAGS, ca);
|
||||
if (optflags != NULL) {
|
||||
delMacro(NULL, "optflags");
|
||||
addMacro(NULL, "optflags", NULL, optflags, RMIL_RPMRC);
|
||||
|
@ -1355,7 +1334,7 @@ int rpmShowRC(FILE *f)
|
|||
|
||||
fprintf(f, "\nRPMRC VALUES:\n");
|
||||
for (i = 0, opt = optionTable; i < optionTableSize; i++, opt++) {
|
||||
char *s = rpmGetVar(opt->var);
|
||||
const char *s = rpmGetVar(opt->var);
|
||||
if (s != NULL || rpmGetVerbosity() < RPMMESS_NORMAL)
|
||||
fprintf(f, "%-21s : %s\n", opt->name, s ? s : "(not set)");
|
||||
}
|
||||
|
|
|
@ -74,7 +74,8 @@ const char * rpmDetectPGPVersion(pgpVersion *pgpVer)
|
|||
char *pgpvbin;
|
||||
struct stat statbuf;
|
||||
|
||||
if (!pgpbin || ! (pgpvbin = (char *)alloca(strlen(pgpbin) + 2))) {
|
||||
if (!(pgpbin && pgpbin[0] != '%') || ! (pgpvbin = (char *)alloca(strlen(pgpbin) + 2))) {
|
||||
if (pgpbin) xfree(pgpbin);
|
||||
saved_pgp_version = -1;
|
||||
return NULL;
|
||||
}
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
#include "system.h"
|
||||
|
||||
#include <rpmlib.h>
|
||||
#include <rpmmacro.h> /* XXX for rpmGetPath */
|
||||
#include <rpmmacro.h> /* XXX for rpmExpand */
|
||||
|
||||
#include "depends.h"
|
||||
#include "fprint.h"
|
||||
|
@ -1029,6 +1029,7 @@ static void handleOverlappedFiles(TFI_t * fi, hashTable ht,
|
|||
ds->needed -= BLOCK_ROUND(fixupSize, ds->block);
|
||||
}
|
||||
}
|
||||
if (filespec) free(filespec);
|
||||
}
|
||||
|
||||
static int ensureOlder(rpmdb db, Header new, int dbOffset, rpmProblemSet probs,
|
||||
|
@ -1413,7 +1414,7 @@ int rpmRunTransactions(rpmTransactionSet ts, rpmCallbackFunction notify,
|
|||
chdir("/");
|
||||
/*@-unrecog@*/ chroot(ts->root); /*@=unrecog@*/
|
||||
|
||||
ht = htCreate(totalFileCount * 2, 0, fpHashFunction, fpEqual);
|
||||
ht = htCreate(totalFileCount * 2, 0, 0, fpHashFunction, fpEqual);
|
||||
fpc = fpCacheCreate(totalFileCount);
|
||||
|
||||
/* ===============================================
|
||||
|
|
26
oldrpmdb.c
26
oldrpmdb.c
|
@ -370,7 +370,7 @@ char * oldrpmdbGetPackageGroup(struct oldrpmdb * oldrpmdb, struct oldrpmdbLabel
|
|||
|
||||
rec = gdbm_fetch(oldrpmdb->groupIndex, key);
|
||||
if (!rec.dptr) {
|
||||
return strdup("Unknown");
|
||||
return xstrdup("Unknown");
|
||||
}
|
||||
|
||||
g = malloc(rec.dsize + 1);
|
||||
|
@ -467,8 +467,8 @@ int oldrpmdbGetPackageInfo(struct oldrpmdb * oldrpmdb, struct oldrpmdbLabel labe
|
|||
list = splitString(rec.dptr, rec.dsize, '\1');
|
||||
free(rec.dptr);
|
||||
|
||||
pinfo->version = strdup(list[1]);
|
||||
pinfo->release = strdup(list[2]);
|
||||
pinfo->version = xstrdup(list[1]);
|
||||
pinfo->release = xstrdup(list[2]);
|
||||
/* list[3] == "1" always */
|
||||
pinfo->name = malloc(strlen(list[0]) + strlen(list[4]) + 2);
|
||||
strcpy(pinfo->name, list[0]);
|
||||
|
@ -484,7 +484,7 @@ int oldrpmdbGetPackageInfo(struct oldrpmdb * oldrpmdb, struct oldrpmdbLabel labe
|
|||
strcat(pinfo->labelstr, ":");
|
||||
strcat(pinfo->labelstr, pinfo->release);
|
||||
|
||||
pinfo->preamble = strdup(list[5]);
|
||||
pinfo->preamble = xstrdup(list[5]);
|
||||
pinfo->installTime = atoi(list[6]);
|
||||
pinfo->fileCount = atoi(list[7]);
|
||||
|
||||
|
@ -498,27 +498,27 @@ int oldrpmdbGetPackageInfo(struct oldrpmdb * oldrpmdb, struct oldrpmdbLabel labe
|
|||
|
||||
for (strptr = prelist; *strptr; strptr++) {
|
||||
if (!strncasecmp("Description: ", *strptr, 13))
|
||||
pinfo->description = strdup((*strptr) + 13);
|
||||
pinfo->description = xstrdup((*strptr) + 13);
|
||||
else if (!strncasecmp("Copyright: ", *strptr, 11))
|
||||
pinfo->copyright = strdup((*strptr) + 11);
|
||||
pinfo->copyright = xstrdup((*strptr) + 11);
|
||||
else if (!strncasecmp("Distribution: ", *strptr, 14))
|
||||
pinfo->distribution = strdup((*strptr) + 14);
|
||||
pinfo->distribution = xstrdup((*strptr) + 14);
|
||||
else if (!strncasecmp("Vendor: ", *strptr, 8))
|
||||
pinfo->vendor = strdup((*strptr) + 8);
|
||||
pinfo->vendor = xstrdup((*strptr) + 8);
|
||||
else if (!strncasecmp("size: ", *strptr, 6))
|
||||
pinfo->size = atoi((*strptr) + 6);
|
||||
else if (!strncasecmp("BuildDate: ", *strptr, 11))
|
||||
pinfo->buildTime =atoi((*strptr) + 11);
|
||||
else if (!strncasecmp("BuildHost: ", *strptr, 11))
|
||||
pinfo->buildHost = strdup((*strptr) + 11);
|
||||
pinfo->buildHost = xstrdup((*strptr) + 11);
|
||||
}
|
||||
freeSplitString(prelist);
|
||||
|
||||
if (!pinfo->vendor) pinfo->vendor = strdup("");
|
||||
if (!pinfo->description) pinfo->description = strdup("");
|
||||
if (!pinfo->distribution) pinfo->distribution = strdup("");
|
||||
if (!pinfo->vendor) pinfo->vendor = xstrdup("");
|
||||
if (!pinfo->description) pinfo->description = xstrdup("");
|
||||
if (!pinfo->distribution) pinfo->distribution = xstrdup("");
|
||||
if (!pinfo->copyright) {
|
||||
pinfo->copyright = strdup("");
|
||||
pinfo->copyright = xstrdup("");
|
||||
fprintf(stdout, _("no copyright!\n"));
|
||||
}
|
||||
|
||||
|
|
394
po/rpm.pot
394
po/rpm.pot
File diff suppressed because it is too large
Load Diff
|
@ -6,7 +6,7 @@
|
|||
msgid ""
|
||||
msgstr ""
|
||||
"Project-Id-Version: PACKAGE VERSION\n"
|
||||
"POT-Creation-Date: 1999-10-26 13:07-0400\n"
|
||||
"POT-Creation-Date: 1999-10-29 09:03-0400\n"
|
||||
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
|
||||
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
|
||||
"Language-Team: LANGUAGE <LL@li.org>\n"
|
||||
|
|
11
popt/popt.c
11
popt/popt.c
|
@ -59,9 +59,13 @@ poptContext poptGetContext(const char * name, int argc, const char ** argv,
|
|||
|
||||
con->leftovers = calloc( (argc + 1), sizeof(char *) );
|
||||
con->options = options;
|
||||
con->aliases = NULL;
|
||||
con->numAliases = 0;
|
||||
con->flags = flags;
|
||||
con->execs = NULL;
|
||||
con->numExecs = 0;
|
||||
con->finalArgvAlloced = argc * 2;
|
||||
con->finalArgv = calloc( con->finalArgvAlloced, sizeof(*con->finalArgv) );
|
||||
con->flags = flags;
|
||||
con->execAbsolute = 1;
|
||||
|
||||
if (getenv("POSIXLY_CORRECT") || getenv("POSIX_ME_HARDER"))
|
||||
|
@ -368,7 +372,7 @@ static /*@only@*/ const char * expandNextArg(poptContext con, const char * s)
|
|||
*te++ = c;
|
||||
}
|
||||
*te = '\0';
|
||||
t = realloc(t, strlen(t));
|
||||
t = realloc(t, strlen(t)); /* XXX memory leak, hard to plug */
|
||||
return t;
|
||||
}
|
||||
|
||||
|
@ -513,6 +517,7 @@ int poptGetNextOpt(poptContext con)
|
|||
|
||||
switch (opt->argInfo & POPT_ARG_MASK) {
|
||||
case POPT_ARG_STRING:
|
||||
/* XXX memory leak, hard to plug */
|
||||
*((const char **) opt->arg) = xstrdup(con->os->nextArg);
|
||||
break;
|
||||
|
||||
|
@ -609,7 +614,7 @@ void poptFreeContext(poptContext con) {
|
|||
if (con->execs[i].longName) xfree(con->execs[i].longName);
|
||||
xfree(con->execs[i].script);
|
||||
}
|
||||
xfree(con->execs);
|
||||
if (con->execs) xfree(con->execs);
|
||||
|
||||
free(con->leftovers);
|
||||
free(con->finalArgv);
|
||||
|
|
|
@ -40,7 +40,7 @@ static void configLine(poptContext con, char * line) {
|
|||
alias.longName = longName, alias.shortName = shortName;
|
||||
poptAddAlias(con, alias, 0);
|
||||
} else if (!strcmp(entryType, "exec")) {
|
||||
con->execs = realloc(con->execs, /* XXX memory leak */
|
||||
con->execs = realloc(con->execs,
|
||||
sizeof(*con->execs) * (con->numExecs + 1));
|
||||
if (longName)
|
||||
con->execs[con->numExecs].longName = xstrdup(longName);
|
||||
|
|
5
rpm.c
5
rpm.c
|
@ -1361,7 +1361,12 @@ int main(int argc, const char ** argv)
|
|||
}
|
||||
|
||||
/* keeps memory leak checkers quiet */
|
||||
freeNames();
|
||||
freeFilesystems();
|
||||
if (qva->qva_queryFormat) xfree(qva->qva_queryFormat);
|
||||
|
||||
#if HAVE_MCHECK_H && HAVE_MTRACE
|
||||
muntrace(); /* Trace malloc only if MALLOC_TRACE=mtrace-output-file. */
|
||||
#endif
|
||||
return ec;
|
||||
}
|
||||
|
|
|
@ -1399,7 +1399,7 @@ rpmExpand(const char *arg, ...)
|
|||
}
|
||||
va_end(ap);
|
||||
expandMacros(NULL, NULL, buf, sizeof(buf));
|
||||
return xstrdup(buf); /* XXX build memory leaks */
|
||||
return xstrdup(buf);
|
||||
}
|
||||
|
||||
int
|
||||
|
|
|
@ -650,7 +650,7 @@ DPRINTF(100, ("\n"));
|
|||
break;
|
||||
}
|
||||
if (l == nlangs)
|
||||
onlylang[nlangs++] = strdup(lang);
|
||||
onlylang[nlangs++] = xstrdup(lang);
|
||||
}
|
||||
lang = NULL;
|
||||
}
|
||||
|
@ -1005,7 +1005,7 @@ main(int argc, char **argv)
|
|||
while((c = getopt(argc, argv, "defgEMl:C:I:O:Tv")) != EOF)
|
||||
switch (c) {
|
||||
case 'C':
|
||||
mastercatalogue = strdup(optarg);
|
||||
mastercatalogue = xstrdup(optarg);
|
||||
break;
|
||||
case 'd':
|
||||
debug++;
|
||||
|
@ -1021,7 +1021,7 @@ main(int argc, char **argv)
|
|||
break;
|
||||
case 'l':
|
||||
gottalang = 1;
|
||||
onlylang[nlangs++] = strdup(optarg);
|
||||
onlylang[nlangs++] = xstrdup(optarg);
|
||||
break;
|
||||
case 'I':
|
||||
inputdir = optarg;
|
||||
|
|
Loading…
Reference in New Issue