From e6318cc57f9581393d6cb534e3dece38b87aa3cb Mon Sep 17 00:00:00 2001 From: jbj Date: Tue, 21 Sep 1999 17:21:57 +0000 Subject: [PATCH] fix: removed files fingerprint memory leak. fix: resurrect allfiles flag from rpm-2.5.x. CVS patchset: 3312 CVS date: 1999/09/21 17:21:57 --- CHANGES | 4 +++- lib/cpio.c | 2 +- lib/depends.c | 5 ++--- lib/fprint.c | 2 +- lib/fs.c | 6 +++--- lib/header.c | 2 +- lib/misc.c | 4 ++-- lib/rpmrc.c | 4 ++-- lib/transaction.c | 47 ++++++++++++++++++++++++++--------------------- po/rpm.pot | 16 ++++++++-------- popt/po/popt.pot | 2 +- popt/poptconfig.c | 2 +- rpm.c | 19 ++++++++++--------- rpm.spec | 2 +- 14 files changed, 62 insertions(+), 55 deletions(-) diff --git a/CHANGES b/CHANGES index 02e8e68..686a6f2 100644 --- a/CHANGES +++ b/CHANGES @@ -57,7 +57,9 @@ - fix: command line install had header memory leak. - check for NULL on all memory allocations. - free rpmrc mallocs on exit. - - permit run time leak detection. + - glibc2: permit run time leak detection. + - fix: removed files fingerprint memory leak. + - fix: resurrect allfiles flag from rpm-2.5.x. 3.0.1 -> 3.0.2 - eliminate armv4 entries from rpmrc (Andrew E. Mileski). diff --git a/lib/cpio.c b/lib/cpio.c index d804701..f22cd9a 100644 --- a/lib/cpio.c +++ b/lib/cpio.c @@ -347,7 +347,7 @@ static int checkDirectory(char * filename) if (lastDirAlloced < (length + 1)) { lastDirAlloced = length + 100; - lastDir = xrealloc(lastDir, lastDirAlloced); + lastDir = xrealloc(lastDir, lastDirAlloced); /* XXX memory leak */ } strcpy(lastDir, buf); diff --git a/lib/depends.c b/lib/depends.c index 7fa4fd0..633485d 100644 --- a/lib/depends.c +++ b/lib/depends.c @@ -492,7 +492,7 @@ rpmTransactionSet rpmtransCreateSet(rpmdb db, const char * root) rpmdep->orderAlloced = 5; rpmdep->orderCount = 0; - rpmdep->order = xcalloc(rpmdep->orderAlloced, sizeof(*rpmdep->order)); + rpmdep->order = xcalloc(rpmdep->orderAlloced, sizeof(*rpmdep->order)); /* XXX memory leak */ return rpmdep; } @@ -1184,8 +1184,7 @@ int rpmdepOrder(rpmTransactionSet rpmdep) qsort(orderList, rpmdep->addedPackages.size, sizeof(*orderList), orderListIndexCmp); - /* XXX memory leak */ - newOrder = xmalloc(sizeof(*newOrder) * rpmdep->orderCount); + newOrder = xmalloc(sizeof(*newOrder) * rpmdep->orderCount); /* XXX memory leak */ for (i = 0, newOrderCount = 0; i < orderingCount; i++) { key.alIndex = ordering[i]; needle = bsearch(&key, orderList, rpmdep->addedPackages.size, diff --git a/lib/fprint.c b/lib/fprint.c index 2c34984..73afd6e 100644 --- a/lib/fprint.c +++ b/lib/fprint.c @@ -96,7 +96,7 @@ static fingerPrint doLookup(const char * fullName, int scareMemory, if (scareMemory) fp.basename = chptr1; else - fp.basename = xstrdup(chptr1); + fp.basename = xstrdup(chptr1); /* XXX memory leak */ fp.ino = sb.st_ino; fp.dev = sb.st_dev; diff --git a/lib/fs.c b/lib/fs.c index e4b3e5b..e92d21b 100644 --- a/lib/fs.c +++ b/lib/fs.c @@ -124,7 +124,7 @@ static int getFilesystemList(void) getmntinfo_r(&mounts, flags, &mntCount, &bufSize); # endif - filesystems = xcalloc((numAlloced + 1), sizeof(*filesystems)); + filesystems = xcalloc((numAlloced + 1), sizeof(*filesystems)); /* XXX memory leak */ while (1) { # if GETMNTENT_ONE @@ -161,7 +161,7 @@ static int getFilesystemList(void) } filesystems[num].dev = sb.st_dev; - filesystems[num].mntPoint = xstrdup(mntdir); + filesystems[num].mntPoint = xstrdup(mntdir); /* XXX memory leak */ num++; } @@ -174,7 +174,7 @@ static int getFilesystemList(void) filesystems[num].dev = 0; filesystems[num].mntPoint = NULL; - fsnames = xcalloc((num + 1), sizeof(*fsnames)); + fsnames = xcalloc((num + 1), sizeof(*fsnames)); /* XXX memory leak */ for (i = 0; i < num; i++) fsnames[i] = filesystems[i].mntPoint; fsnames[num] = NULL; diff --git a/lib/header.c b/lib/header.c index d27414b..c02a68f 100644 --- a/lib/header.c +++ b/lib/header.c @@ -135,7 +135,7 @@ static void copyEntry(struct indexEntry * entry, /*@out@*/int_32 *type, ptrEntry = *p = xmalloc(tableSize); chptr = entry->data; } else { - ptrEntry = *p = xmalloc(tableSize + entry->length); + ptrEntry = *p = xmalloc(tableSize + entry->length); /* XXX memory leak */ chptr = ((char *) *p) + tableSize; memcpy(chptr, entry->data, entry->length); } diff --git a/lib/misc.c b/lib/misc.c index 2aa2801..c875589 100644 --- a/lib/misc.c +++ b/lib/misc.c @@ -222,7 +222,7 @@ int unameToUid(char * thisUname, uid_t * uid) { strcmp(thisUname, lastUname)) { if (lastUnameAlloced < thisUnameLen + 1) { lastUnameAlloced = thisUnameLen + 10; - lastUname = xrealloc(lastUname, lastUnameAlloced); + lastUname = xrealloc(lastUname, lastUnameAlloced); /* XXX memory leak */ } strcpy(lastUname, thisUname); @@ -262,7 +262,7 @@ int gnameToGid(char * thisGname, gid_t * gid) { strcmp(thisGname, lastGname)) { if (lastGnameAlloced < thisGnameLen + 1) { lastGnameAlloced = thisGnameLen + 10; - lastGname = xrealloc(lastGname, lastGnameAlloced); + lastGname = xrealloc(lastGname, lastGnameAlloced); /* XXX memory leak */ } strcpy(lastGname, thisGname); diff --git a/lib/rpmrc.c b/lib/rpmrc.c index 961c394..dc5de28 100644 --- a/lib/rpmrc.c +++ b/lib/rpmrc.c @@ -259,9 +259,9 @@ static void machAddEquiv(struct machEquivTable * table, char * name, table->list = xrealloc(table->list, (table->count + 1) * sizeof(*table->list)); else - table->list = xmalloc(sizeof(*table->list)); + table->list = xmalloc(sizeof(*table->list)); /* XXX memory leak */ - table->list[table->count].name = xstrdup(name); + table->list[table->count].name = xstrdup(name); /* XXX memory leak */ table->list[table->count++].score = distance; } } diff --git a/lib/transaction.c b/lib/transaction.c index b5e3326..b0e3c54 100644 --- a/lib/transaction.c +++ b/lib/transaction.c @@ -138,7 +138,7 @@ static rpmProblemSet psCreate(void) { rpmProblemSet probs; - probs = xmalloc(sizeof(*probs)); + probs = xmalloc(sizeof(*probs)); /* XXX memory leak */ probs->numProblems = probs->numProblemsAlloced = 0; probs->probs = NULL; @@ -470,7 +470,7 @@ static enum fileTypes whatis(short mode) static enum fileActions decideFileFate(const char * filespec, short dbMode, const char * dbMd5, const char * dbLink, short newMode, const char * newMd5, const char * newLink, int newFlags, - int brokenMd5) + int brokenMd5, int transFlags) { char buffer[1024]; const char * dbAttr, * newAttr; @@ -480,9 +480,12 @@ static enum fileActions decideFileFate(const char * filespec, short dbMode, int save = (newFlags & RPMFILE_NOREPLACE) ? FA_ALTNAME : FA_SAVE; if (lstat(filespec, &sb)) { - /* the file doesn't exist on the disk create it unless the new - package has marked it as missingok */ - if (newFlags & RPMFILE_MISSINGOK) { + /* + * The file doesn't exist on the disk. Create it unless the new + * package has marked it as missingok, or allfiles is requested. + */ + if (!(transFlags & RPMTRANS_FLAG_ALLFILES) && + (newFlags & RPMFILE_MISSINGOK)) { rpmMessage(RPMMESS_DEBUG, _("%s skipped due to missingok flag\n"), filespec); return FA_SKIP; @@ -538,8 +541,7 @@ static enum fileActions decideFileFate(const char * filespec, short dbMode, possible in case something else (like the timestamp) has changed */ if (!strcmp(dbAttr, buffer)) { - /* this config file has never been modified, so - just replace it */ + /* this config file has never been modified, so just replace it */ return FA_CREATE; } @@ -548,11 +550,12 @@ static enum fileActions decideFileFate(const char * filespec, short dbMode, return FA_SKIP; } - /* the config file on the disk has been modified, but - the ones in the two packages are different. It would - be nice if RPM was smart enough to at least try and - merge the difference ala CVS, but... */ - + /* + * The config file on the disk has been modified, but + * the ones in the two packages are different. It would + * be nice if RPM was smart enough to at least try and + * merge the difference ala CVS, but... + */ return save; } @@ -577,7 +580,7 @@ static int filecmp(short mode1, const char * md51, const char * link1, static int handleInstInstalledFiles(TFI_t * fi, rpmdb db, struct sharedFileInfo * shared, int sharedCount, int reportConflicts, - rpmProblemSet probs) + rpmProblemSet probs, int transFlags) { Header h; int i; @@ -640,7 +643,8 @@ static int handleInstInstalledFiles(TFI_t * fi, rpmdb db, fi->fmd5s[fileNum], fi->flinks[fileNum], fi->fflags[fileNum], - !headerIsEntry(h, RPMTAG_RPMVERSION)); + !headerIsEntry(h, RPMTAG_RPMVERSION), + transFlags); } fi->replacedSizes[fileNum] = otherSizes[otherFileNum]; @@ -650,7 +654,7 @@ static int handleInstInstalledFiles(TFI_t * fi, rpmdb db, free(otherLinks); headerFree(h); - fi->replaced = xrealloc(fi->replaced, + fi->replaced = xrealloc(fi->replaced, /* XXX memory leak */ sizeof(*fi->replaced) * (numReplaced + 1)); fi->replaced[numReplaced].otherPkg = 0; @@ -992,7 +996,7 @@ static void skipFiles(TFI_t * fi, int noDocs) int rpmRunTransactions(rpmTransactionSet ts, rpmCallbackFunction notify, void * notifyData, rpmProblemSet okProbs, - rpmProblemSet * newProbs, int flags, int ignoreSet) + rpmProblemSet * newProbs, int transFlags, int ignoreSet) { int i, j; int rc, ourrc = 0; @@ -1220,7 +1224,7 @@ int rpmRunTransactions(rpmTransactionSet ts, rpmCallbackFunction notify, fi->replacedSizes = xcalloc(fi->fc, sizeof(*fi->replacedSizes)); /* Skip netshared paths, not our i18n files, and excluded docs */ - skipFiles(fi, flags & RPMTRANS_FLAG_NODOCS); + skipFiles(fi, transFlags & RPMTRANS_FLAG_NODOCS); break; } @@ -1332,7 +1336,7 @@ int rpmRunTransactions(rpmTransactionSet ts, rpmCallbackFunction notify, case TR_ADDED: handleInstInstalledFiles(fi, ts->db, shared, nexti - i, !(beingRemoved || (ignoreSet & RPMPROB_FILTER_REPLACEOLDFILES)), - probs); + probs, transFlags); break; case TR_REMOVED: if (!beingRemoved) @@ -1386,6 +1390,7 @@ int rpmRunTransactions(rpmTransactionSet ts, rpmCallbackFunction notify, free(fi->fps); fi->fps = NULL; break; case TR_REMOVED: + free(fi->fps); fi->fps = NULL; break; } } @@ -1393,7 +1398,7 @@ int rpmRunTransactions(rpmTransactionSet ts, rpmCallbackFunction notify, /* =============================================== * If unfiltered problems exist, free memory and return. */ - if ((flags & RPMTRANS_FLAG_BUILD_PROBS) || + if ((transFlags & RPMTRANS_FLAG_BUILD_PROBS) || (probs->numProblems && (!okProbs || psTrim(okProbs, probs)))) { *newProbs = probs; @@ -1439,7 +1444,7 @@ int rpmRunTransactions(rpmTransactionSet ts, rpmCallbackFunction notify, if (fd) { if (installBinaryPackage(ts->root, ts->db, fd, - hdrs[i], flags, notify, + hdrs[i], transFlags, notify, notifyData, alp->key, fi->actions, fi->fc ? fi->replaced : NULL, ts->scriptFd)) { @@ -1461,7 +1466,7 @@ int rpmRunTransactions(rpmTransactionSet ts, rpmCallbackFunction notify, if (ts->order[oc].u.removed.dependsOnIndex == lastFailed) break; if (removeBinaryPackage(ts->root, ts->db, fi->record, - flags, fi->actions, ts->scriptFd)) + transFlags, fi->actions, ts->scriptFd)) ourrc++; break; } diff --git a/po/rpm.pot b/po/rpm.pot index 1d09962..4197c25 100644 --- a/po/rpm.pot +++ b/po/rpm.pot @@ -6,7 +6,7 @@ msgid "" msgstr "" "Project-Id-Version: PACKAGE VERSION\n" -"POT-Creation-Date: 1999-09-20 23:21-0400\n" +"POT-Creation-Date: 1999-09-21 17:19-0400\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" @@ -1196,23 +1196,23 @@ msgstr "" msgid "no packages given for uninstall" msgstr "" -#: ../rpm.c:1291 +#: ../rpm.c:1292 msgid "no packages given for install" msgstr "" -#: ../rpm.c:1314 +#: ../rpm.c:1315 msgid "extra arguments given for query of all packages" msgstr "" -#: ../rpm.c:1319 +#: ../rpm.c:1320 msgid "no arguments given for query" msgstr "" -#: ../rpm.c:1336 +#: ../rpm.c:1337 msgid "extra arguments given for verify of all packages" msgstr "" -#: ../rpm.c:1340 +#: ../rpm.c:1341 msgid "no arguments given for verify" msgstr "" @@ -1993,7 +1993,7 @@ msgstr "" msgid "package %s conflicts: %s\n" msgstr "" -#: ../lib/depends.c:977 ../lib/depends.c:1282 +#: ../lib/depends.c:977 ../lib/depends.c:1281 #, c-format msgid "cannot read header at %d for dependency check" msgstr "" @@ -3242,7 +3242,7 @@ msgstr "" msgid "excluding %s\n" msgstr "" -#: ../lib/transaction.c:486 +#: ../lib/transaction.c:489 #, c-format msgid "%s skipped due to missingok flag\n" msgstr "" diff --git a/popt/po/popt.pot b/popt/po/popt.pot index e4f1f94..8848085 100644 --- a/popt/po/popt.pot +++ b/popt/po/popt.pot @@ -6,7 +6,7 @@ msgid "" msgstr "" "Project-Id-Version: PACKAGE VERSION\n" -"POT-Creation-Date: 1999-09-04 10:55-0400\n" +"POT-Creation-Date: 1999-09-21 14:38-0400\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" diff --git a/popt/poptconfig.c b/popt/poptconfig.c index ea670e7..9d9b495 100644 --- a/popt/poptconfig.c +++ b/popt/poptconfig.c @@ -55,7 +55,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, + con->execs = realloc(con->execs, /* XXX memory leak */ sizeof(*con->execs) * (con->numExecs + 1)); if (longName) con->execs[con->numExecs].longName = strdup(longName); diff --git a/rpm.c b/rpm.c index c84f4d4..1c6959b 100755 --- a/rpm.c +++ b/rpm.c @@ -1268,24 +1268,25 @@ int main(int argc, char ** argv) if (ignoreOs) probFilter |= RPMPROB_FILTER_IGNOREOS; if (ignoreSize) probFilter |= RPMPROB_FILTER_DISKSPACE; - if (allFiles) installFlags |= RPMTRANS_FLAG_ALLFILES; - if (justdb) installFlags |= RPMTRANS_FLAG_JUSTDB; if (test) installFlags |= RPMTRANS_FLAG_TEST; + /* RPMTRANS_FLAG_BUILD_PROBS */ if (noScripts) installFlags |= RPMTRANS_FLAG_NOSCRIPTS; + if (justdb) installFlags |= RPMTRANS_FLAG_JUSTDB; if (noTriggers) installFlags |= RPMTRANS_FLAG_NOTRIGGERS; - - if (showPercents) interfaceFlags |= INSTALL_PERCENT; - if (showHash) interfaceFlags |= INSTALL_HASH; - if (noDeps) interfaceFlags |= INSTALL_NODEPS; - if (noOrder) interfaceFlags |= INSTALL_NOORDER; - if (upgrade) interfaceFlags |= INSTALL_UPGRADE; - if (!incldocs) { if (excldocs) installFlags |= RPMTRANS_FLAG_NODOCS; else if (rpmExpandNumeric("%{_excludedocs}")) installFlags |= RPMTRANS_FLAG_NODOCS; } + if (allFiles) installFlags |= RPMTRANS_FLAG_ALLFILES; + /* RPMTRANS_FLAG_KEEPOBSOLETE */ + + if (showPercents) interfaceFlags |= INSTALL_PERCENT; + if (showHash) interfaceFlags |= INSTALL_HASH; + if (noDeps) interfaceFlags |= INSTALL_NODEPS; + if (noOrder) interfaceFlags |= INSTALL_NOORDER; + if (upgrade) interfaceFlags |= INSTALL_UPGRADE; if (!poptPeekArg(optCon)) argerror(_("no packages given for install")); diff --git a/rpm.spec b/rpm.spec index 156e40d..58a3e31 100644 --- a/rpm.spec +++ b/rpm.spec @@ -2,7 +2,7 @@ Summary: The Red Hat package management system. Name: rpm %define version 3.0.3 Version: %{version} -Release: 0.29 +Release: 0.30 Group: System Environment/Base Source: ftp://ftp.rpm.org/pub/rpm/dist/rpm-3.0.x/rpm-%{version}.tar.gz Copyright: GPL -- 2.7.4