fix: command line install had header memory leak.
authorjbj <devnull@localhost>
Tue, 21 Sep 1999 03:22:53 +0000 (03:22 +0000)
committerjbj <devnull@localhost>
Tue, 21 Sep 1999 03:22:53 +0000 (03:22 +0000)
check for NULL on all memory allocations.
free rpmrc mallocs on exit.
permit run time leak detection.

CVS patchset: 3311
CVS date: 1999/09/21 03:22:53

50 files changed:
CHANGES
build.c
build/expression.c
build/files.c
build/names.c
build/pack.c
build/parseFiles.c
build/parsePreamble.c
build/parsePrep.c
build/parseReqs.c
build/parseScript.c
build/parseSpec.c
build/spec.c
configure.in
convertdb.c
lib/Makefile.am
lib/cpio.c
lib/dbindex.c
lib/depends.c
lib/falloc.c
lib/formats.c
lib/fprint.c
lib/fs.c
lib/hash.c
lib/header.c
lib/header.h
lib/install.c
lib/macro.c
lib/misc.c
lib/oldheader.c
lib/package.c
lib/problems.c
lib/query.c
lib/rebuilddb.c
lib/rpmdb.c
lib/rpminstall.c
lib/rpmlib.h
lib/rpmrc.c
lib/signature.c
lib/stringbuf.c
lib/transaction.c
lib/uninstall.c
lib/url.c
oldrpmdb.c
po/rpm.pot
rpm.c
rpm.spec
rpmio/macro.c
system.h
tools/rpmgettext.c

diff --git a/CHANGES b/CHANGES
index e03910c..02e8e68 100644 (file)
--- a/CHANGES
+++ b/CHANGES
        - do versioned provides/conflicts resolution correctly.
        - rpmpopt: display versioned provides/obsoletes.
        - revert to shared libbz2.so now that bzip2 is in base install.
+       - 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.
 
 3.0.1 -> 3.0.2
        - eliminate armv4 entries from rpmrc (Andrew E. Mileski).
diff --git a/build.c b/build.c
index 833678a..e3fe075 100644 (file)
--- a/build.c
+++ b/build.c
@@ -1,7 +1,6 @@
 #include "system.h"
 
-#include "build/rpmbuild.h"
-#include "popt/popt.h"
+#include "rpmbuild.h"
 #include "build.h"
 #include "install.h"
 
@@ -312,7 +311,7 @@ static void buildArgCallback(poptContext con, enum poptCallbackReason reason,
            fprintf(stderr, _("buildroot already specified"));
            exit(EXIT_FAILURE);
        }
-       data->buildRootOverride = strdup(arg);
+       data->buildRootOverride = xstrdup(arg);
        break;
     case POPT_BUILDARCH:
        fprintf(stderr, _("--buildarch has been obsoleted.  Use the --target option instead.\n")); 
@@ -325,10 +324,10 @@ static void buildArgCallback(poptContext con, enum poptCallbackReason reason,
     case POPT_TARGETPLATFORM:
        if (data->targets) {
            int len = strlen(data->targets) + strlen(arg) + 2;
-           data->targets = realloc(data->targets, len);
+           data->targets = xrealloc(data->targets, len);
            strcat(data->targets, ",");
        } else {
-           data->targets = malloc(strlen(arg) + 1);
+           data->targets = xmalloc(strlen(arg) + 1);
            data->targets[0] = '\0';
        }
        strcat(data->targets, arg);
index e4b0601..1b053d4 100644 (file)
@@ -43,7 +43,7 @@ static Value valueMakeInteger(int i)
 {
   Value v;
 
-  v = (Value) malloc(sizeof(struct _value));
+  v = (Value) xmalloc(sizeof(struct _value));
   v->type = VALUE_TYPE_INTEGER;
   v->data.i = i;
   return v;
@@ -53,9 +53,9 @@ static Value valueMakeString(const char *s)
 {
   Value v;
 
-  v = (Value) malloc(sizeof(struct _value));
+  v = (Value) xmalloc(sizeof(struct _value));
   v->type = VALUE_TYPE_STRING;
-  v->data.s = strdup(s);
+  v->data.s = xstrdup(s);
   return v;
 }
 
@@ -473,7 +473,7 @@ static Value doAddSubtract(ParseState state)
        return NULL;
       }
 
-      copy = malloc(strlen(v1->data.s) + strlen(v2->data.s) + 1);
+      copy = xmalloc(strlen(v1->data.s) + strlen(v2->data.s) + 1);
       strcpy(copy, v1->data.s);
       strcat(copy, v2->data.s);
 
@@ -628,7 +628,7 @@ int parseExpressionBoolean(Spec spec, char *expr)
   DEBUG(printf("parseExprBoolean(?, '%s')\n", expr));
 
   /* Initialize the expression parser state. */
-  state.str = state.p = strdup(expr);
+  state.str = state.p = xstrdup(expr);
   state.spec = spec;
   rdToken(&state);
 
@@ -673,7 +673,7 @@ char * parseExpressionString(Spec spec, char *expr)
   DEBUG(printf("parseExprString(?, '%s')\n", expr));
 
   /* Initialize the expression parser state. */
-  state.str = state.p = strdup(expr);
+  state.str = state.p = xstrdup(expr);
   state.spec = spec;
   rdToken(&state);
 
@@ -697,10 +697,10 @@ char * parseExpressionString(Spec spec, char *expr)
   case VALUE_TYPE_INTEGER: {
     char buf[128];
     sprintf(buf, "%d", v->data.i);
-    result = strdup(buf);
+    result = xstrdup(buf);
   } break;
   case VALUE_TYPE_STRING:
-    result = strdup(v->data.s);
+    result = xstrdup(v->data.s);
     break;
   default:
     break;
index 7ad5387..af597f5 100644 (file)
@@ -94,13 +94,13 @@ static void dupAttrRec(AttrRec *oar, AttrRec *nar) {
     freeAttrRec(nar);
     *nar = *oar;               /* structure assignment */
     if (nar->ar_fmodestr)
-       nar->ar_fmodestr = strdup(nar->ar_fmodestr);
+       nar->ar_fmodestr = xstrdup(nar->ar_fmodestr);
     if (nar->ar_dmodestr)
-       nar->ar_dmodestr = strdup(nar->ar_dmodestr);
+       nar->ar_dmodestr = xstrdup(nar->ar_dmodestr);
     if (nar->ar_user)
-       nar->ar_user = strdup(nar->ar_user);
+       nar->ar_user = xstrdup(nar->ar_user);
     if (nar->ar_group)
-       nar->ar_group = strdup(nar->ar_group);
+       nar->ar_group = xstrdup(nar->ar_group);
 }
 
 #if 0
@@ -564,9 +564,9 @@ static int parseForLang(char *buf, struct FileList *fl)
 
        /* Add new locale */
        fl->currentLangs = (const char **) ((fl->currentLangs == NULL)
-         ? malloc(sizeof(*fl->currentLangs))
-         : realloc(fl->currentLangs,(fl->nLangs+1)*sizeof(*fl->currentLangs)));
-       newp = malloc( np+1 );
+         ? xmalloc(sizeof(*fl->currentLangs))
+         : xrealloc(fl->currentLangs,((fl->nLangs+1)*sizeof(*fl->currentLangs))));
+       newp = xmalloc( np+1 );
        strncpy(newp, p, np);
        newp[np] = '\0';
        fl->currentLangs[fl->nLangs++] = newp;
@@ -652,7 +652,7 @@ static int parseForSimple(Spec spec, Package pkg, char *buf,
                fl->processingFailed = 1;
                res = 1;
            }
-           fl->docDirs[fl->docDirCount++] = strdup(s);
+           fl->docDirs[fl->docDirCount++] = xstrdup(s);
            if (strtokWithQuotes(NULL, " \t\n")) {
                rpmError(RPMERR_INTERNAL, _("Only one arg for %%docdir"));
                fl->processingFailed = 1;
@@ -785,7 +785,7 @@ static void genCpioListAndHeader(struct FileList *fl,
     }
 
     *cpioCount = 0;
-    clp = *cpioList = malloc(sizeof(**cpioList) * fl->fileListRecsUsed);
+    clp = *cpioList = xmalloc(sizeof(**cpioList) * fl->fileListRecsUsed);
 
     for (flp = fl->fileList, count = fl->fileListRecsUsed; count > 0; flp++, count--) {
        if ((count > 1) && !strcmp(flp->fileName, flp[1].fileName)) {
@@ -795,8 +795,8 @@ static void genCpioListAndHeader(struct FileList *fl,
        
        /* Make the cpio list */
        if (! (flp->flags & RPMFILE_GHOST)) {
-           clp->fsPath = strdup(flp->diskName);
-           clp->archivePath = strdup(flp->fileName + skipLen);
+           clp->fsPath = xstrdup(flp->diskName);
+           clp->archivePath = xstrdup(flp->fileName + skipLen);
            clp->finalMode = flp->fl_mode;
            clp->finalUid = flp->fl_uid;
            clp->finalGid = flp->fl_gid;
@@ -1022,7 +1022,7 @@ static int addFile(struct FileList *fl, const char *name, struct stat *statp)
     /* Add to the file list */
     if (fl->fileListRecsUsed == fl->fileListRecsAlloced) {
        fl->fileListRecsAlloced += 128;
-       fl->fileList = realloc(fl->fileList,
+       fl->fileList = xrealloc(fl->fileList,
                        fl->fileListRecsAlloced * sizeof(*(fl->fileList)));
     }
            
@@ -1033,8 +1033,8 @@ static int addFile(struct FileList *fl, const char *name, struct stat *statp)
        flp->fl_uid = fileUid;
        flp->fl_gid = fileGid;
 
-       flp->fileName = strdup(fileName);
-       flp->diskName = strdup(diskName);
+       flp->fileName = xstrdup(fileName);
+       flp->diskName = xstrdup(diskName);
        flp->uname = fileUname;
        flp->gname = fileGname;
 
@@ -1046,7 +1046,7 @@ static int addFile(struct FileList *fl, const char *name, struct stat *statp)
            for (i = 0; i < fl->nLangs; i++)
                nl += strlen(fl->currentLangs[i]) + 1;
 
-           flp->langs = ncl = malloc(nl);
+           flp->langs = ncl = xmalloc(nl);
            for (i = 0; i < fl->nLangs; i++) {
                const char *ocl;
                if (i)  *ncl++ = '|';
@@ -1055,9 +1055,9 @@ static int addFile(struct FileList *fl, const char *name, struct stat *statp)
                *ncl = '\0';
            }
        } else if (! parseForRegexLang(fileName, &lang)) {
-           flp->langs = strdup(lang);
+           flp->langs = xstrdup(lang);
        } else {
-           flp->langs = strdup("");
+           flp->langs = xstrdup("");
        }
 
        flp->flags = fl->currentFlags;
@@ -1160,7 +1160,7 @@ static int processPackageFiles(Spec spec, Package pkg,
 
     if (headerGetEntry(pkg->header, RPMTAG_DEFAULTPREFIX,
                       NULL, (void **)&fl.prefix, NULL)) {
-       fl.prefix = strdup(fl.prefix);
+       fl.prefix = xstrdup(fl.prefix);
     } else {
        fl.prefix = NULL;
     }
@@ -1180,10 +1180,10 @@ static int processPackageFiles(Spec spec, Package pkg,
     fl.defVerifyFlags = RPMVERIFY_ALL;
 
     fl.docDirCount = 0;
-    fl.docDirs[fl.docDirCount++] = strdup("/usr/doc");
-    fl.docDirs[fl.docDirCount++] = strdup("/usr/man");
-    fl.docDirs[fl.docDirCount++] = strdup("/usr/info");
-    fl.docDirs[fl.docDirCount++] = strdup("/usr/X11R6/man");
+    fl.docDirs[fl.docDirCount++] = xstrdup("/usr/doc");
+    fl.docDirs[fl.docDirCount++] = xstrdup("/usr/man");
+    fl.docDirs[fl.docDirCount++] = xstrdup("/usr/info");
+    fl.docDirs[fl.docDirCount++] = xstrdup("/usr/X11R6/man");
     fl.docDirs[fl.docDirCount++] = rpmGetPath("%{_docdir}", NULL);
     fl.docDirs[fl.docDirCount++] = rpmGetPath("%{_mandir}", NULL);
     fl.docDirs[fl.docDirCount++] = rpmGetPath("%{_infodir}", NULL);
@@ -1237,7 +1237,7 @@ static int processPackageFiles(Spec spec, Package pkg,
        if (fl.isSpecialDoc) {
            /* Save this stuff for last */
            FREE(specialDoc);
-           specialDoc = strdup(fileName);
+           specialDoc = xstrdup(fileName);
            dupAttrRec(&fl.cur_ar, &specialDocAttrRec);
        } else {
            processBinaryFile(pkg, &fl, fileName);
@@ -1421,7 +1421,7 @@ int processSourceFiles(Spec spec)
     spec->sourceCpioList = NULL;
     spec->sourceCpioCount = 0;
 
-    fl.fileList = malloc((spec->numSources + 1) * sizeof(FileListRec));
+    fl.fileList = xmalloc((spec->numSources + 1) * sizeof(FileListRec));
     fl.processingFailed = 0;
     fl.fileListRecsUsed = 0;
     fl.totalFileSize = 0;
@@ -1447,21 +1447,21 @@ int processSourceFiles(Spec spec)
            flp->flags |= RPMFILE_GHOST;
            s++;
        }
-       flp->diskName = strdup(s);
+       flp->diskName = xstrdup(s);
        fn = strrchr(s, '/');
        if (fn) {
            fn++;
        } else {
            fn = s;
        }
-       flp->fileName = strdup(fn);
+       flp->fileName = xstrdup(fn);
        flp->verifyFlags = RPMVERIFY_ALL;
 
        stat(s, &flp->fl_st);
 
        flp->uname = getUname(flp->fl_uid);
        flp->gname = getGname(flp->fl_gid);
-       flp->langs = strdup("");
+       flp->langs = xstrdup("");
        
        fl.totalFileSize += flp->fl_size;
        
index b30d8a7..5e3b47d 100644 (file)
@@ -37,7 +37,7 @@ char *getUname(uid_t uid)
     uids[x] = uid;
     uid_used++;
     if (pw) {
-       unames[x] = strdup(pw->pw_name);
+       unames[x] = xstrdup(pw->pw_name);
     } else {
        unames[x] = NULL;
     }
@@ -69,10 +69,10 @@ char *getUnameS(const char *uname)
     uid_used++;
     if (pw) {
         uids[x] = pw->pw_uid;
-       unames[x] = strdup(pw->pw_name);
+       unames[x] = xstrdup(pw->pw_name);
     } else {
         uids[x] = -1;
-       unames[x] = strdup(uname);
+       unames[x] = xstrdup(uname);
     }
     return unames[x];
 }
@@ -102,7 +102,7 @@ char *getGname(gid_t gid)
     gids[x] = gid;
     gid_used++;
     if (gr) {
-       gnames[x] = strdup(gr->gr_name);
+       gnames[x] = xstrdup(gr->gr_name);
     } else {
        gnames[x] = NULL;
     }
@@ -134,10 +134,10 @@ char *getGnameS(const char *gname)
     gid_used++;
     if (gr) {
        gids[x] = gr->gr_gid;
-       gnames[x] = strdup(gr->gr_name);
+       gnames[x] = xstrdup(gr->gr_name);
     } else {
        gids[x] = -1;
-       gnames[x] = strdup(gname);
+       gnames[x] = xstrdup(gname);
     }
     return gnames[x];
 }
index 0a0ba7a..7948a7e 100644 (file)
@@ -29,7 +29,7 @@ static inline int genSourceRpmName(Spec spec)
        headerNVR(spec->packages->header, &name, &version, &release);
        sprintf(fileName, "%s-%s-%s.%ssrc.rpm", name, version, release,
            spec->noSource ? "no" : "");
-       spec->sourceRpmName = strdup(fileName);
+       spec->sourceRpmName = xstrdup(fileName);
     }
 
     return 0;
@@ -235,7 +235,7 @@ int writeRPM(Header h, const char *fileName, int type,
     /* Create and add the cookie */
     if (cookie) {
        sprintf(buf, "%s %d", buildHost(), (int) time(NULL));
-       *cookie = strdup(buf);
+       *cookie = xstrdup(buf);
        headerAddEntry(h, RPMTAG_COOKIE, RPM_STRING_TYPE, *cookie, 1);
     }
     
index a34da39..2c6f2c4 100644 (file)
@@ -77,7 +77,7 @@ int parseFiles(Spec spec)
     }
 
     if (file) {
-       pkg->fileFile = strdup(file);
+       pkg->fileFile = xstrdup(file);
     }
     pkg->fileList = newStringBuf();
     
index 0fb035a..bf05a63 100644 (file)
@@ -241,7 +241,7 @@ static int readIcon(Header h, const char *file)
        goto exit;
     }
 
-    icon = malloc(statbuf.st_size);
+    icon = xmalloc(statbuf.st_size);
     *icon = '\0';
     fd = fdOpen(fn, O_RDONLY, 0);
     nb = fdRead(fd, icon, statbuf.st_size);
@@ -277,20 +277,20 @@ stashSt(Spec spec, Header h, int tag, const char *lang)
     if (st) {
        if (st->st_ntags == st->st_nalloc) {
            st->st_nalloc += 10;
-           st->st_t = realloc(st->st_t, st->st_nalloc * sizeof(*(st->st_t)));
+           st->st_t = xrealloc(st->st_t, st->st_nalloc * sizeof(*(st->st_t)));
        }
        t = st->st_t + st->st_ntags++;
        t->t_tag = tag;
        t->t_startx = spec->lineNum - 1;
        t->t_nlines = 1;
-       t->t_lang = strdup(lang);
+       t->t_lang = xstrdup(lang);
        t->t_msgid = NULL;
        if (!(t->t_lang && strcmp(t->t_lang, RPMBUILD_DEFAULT_LANG))) {
            char *n;
            if (headerGetEntry(h, RPMTAG_NAME, NULL, (void **) &n, NULL)) {
                char buf[1024];
                sprintf(buf, "%s(%s)", n, tagName(tag));
-               t->t_msgid = strdup(buf);
+               t->t_msgid = xstrdup(buf);
            }
        }
     }
@@ -385,10 +385,10 @@ static int handlePreambleTag(Spec spec, Package pkg, int tag, char *macro,
        if (spec->buildRoot == NULL) {
            const char *buildroot = rpmGetPath("%{buildroot}", NULL);
            if (buildroot && *buildroot != '%') {
-               spec->buildRoot = strdup(cleanFileName(buildroot));
+               spec->buildRoot = xstrdup(cleanFileName(buildroot));
                macro = NULL;
            } else {
-               spec->buildRoot = strdup(cleanFileName(field));
+               spec->buildRoot = xstrdup(cleanFileName(field));
            }
            xfree(buildroot);
        } else {
index 40a2399..6f3bba5 100644 (file)
@@ -236,14 +236,14 @@ static int doSetupMacro(Spec spec, char *line)
     }
 
     if (dirName) {
-       spec->buildSubdir = strdup(dirName);
+       spec->buildSubdir = xstrdup(dirName);
     } else {
        headerGetEntry(spec->packages->header, RPMTAG_VERSION, NULL,
                 (void **) &version, NULL);
        headerGetEntry(spec->packages->header, RPMTAG_NAME, NULL,
                 (void **) &name, NULL);
        sprintf(buf, "%s-%s", name, version);
-       spec->buildSubdir = strdup(buf);
+       spec->buildSubdir = xstrdup(buf);
     }
     
     free(argv);
index 8f63b78..36522ba 100644 (file)
@@ -110,7 +110,7 @@ int parseRCPOT(Spec spec, Package pkg, const char *field, int tag, int index)
 
        re = r;
        SKIPNONWHITE(re);
-       req = malloc((re-r) + 1);
+       req = xmalloc((re-r) + 1);
        strncpy(req, r, (re-r));
        req[re-r] = '\0';
 
@@ -173,7 +173,7 @@ int parseRCPOT(Spec spec, Package pkg, const char *field, int tag, int index)
                        spec->lineNum, spec->line);
                return RPMERR_BADSPEC;
            }
-           version = malloc((ve-v) + 1);
+           version = xmalloc((ve-v) + 1);
            strncpy(version, v, (ve-v));
            version[ve-v] = '\0';
            re = ve;    /* ==> next token after version string starts here */
index cab1234..8ce55a0 100644 (file)
@@ -18,11 +18,11 @@ static int addTriggerIndex(Package pkg, char *file, char *script, char *prog)
        index = last->index + 1;
     }
 
-    new = malloc(sizeof(*new));
+    new = xmalloc(sizeof(*new));
 
-    new->fileName = (file) ? strdup(file) : NULL;
-    new->script = (*script) ? strdup(script) : NULL;
-    new->prog = strdup(prog);
+    new->fileName = (file) ? xstrdup(file) : NULL;
+    new->script = (*script) ? xstrdup(script) : NULL;
+    new->prog = xstrdup(prog);
     new->index = index;
     new->next = NULL;
 
@@ -259,19 +259,19 @@ int parseScript(Spec spec, int parsePart)
        if (file) {
            switch (parsePart) {
              case PART_PRE:
-               pkg->preInFile = strdup(file);
+               pkg->preInFile = xstrdup(file);
                break;
              case PART_POST:
-               pkg->postInFile = strdup(file);
+               pkg->postInFile = xstrdup(file);
                break;
              case PART_PREUN:
-               pkg->preUnFile = strdup(file);
+               pkg->preUnFile = xstrdup(file);
                break;
              case PART_POSTUN:
-               pkg->postUnFile = strdup(file);
+               pkg->postUnFile = xstrdup(file);
                break;
              case PART_VERIFYSCRIPT:
-               pkg->verifyFile = strdup(file);
+               pkg->verifyFile = xstrdup(file);
                break;
            }
        }
index 41a6c69..3e42535 100644 (file)
@@ -96,7 +96,7 @@ static void forceIncludeFile(Spec spec, const char * fileName)
     OFI_t * ofi;
 
     ofi = newOpenFileInfo();
-    ofi->fileName = strdup(fileName);
+    ofi->fileName = xstrdup(fileName);
     ofi->next = spec->fileStack;
     spec->fileStack = ofi;
 }
@@ -206,10 +206,10 @@ retry:
            struct speclines *sl = spec->sl;
            if (sl->sl_nlines == sl->sl_nalloc) {
                sl->sl_nalloc += 100;
-               sl->sl_lines = (char **)realloc(sl->sl_lines, 
+               sl->sl_lines = (char **) xrealloc(sl->sl_lines, 
                        sl->sl_nalloc * sizeof(*(sl->sl_lines)));
            }
-           sl->sl_lines[sl->sl_nlines++] = strdup(ofi->readBuf);
+           sl->sl_lines[sl->sl_nlines++] = xstrdup(ofi->readBuf);
        }
     }
     
@@ -294,7 +294,7 @@ retry:
     }
 
     if (match != -1) {
-       rl = malloc(sizeof(struct ReadLevelEntry));
+       rl = xmalloc(sizeof(struct ReadLevelEntry));
        rl->reading = spec->readStack->reading && match;
        rl->next = spec->readStack;
        spec->readStack = rl;
@@ -339,12 +339,12 @@ int parseSpec(Spec *specp, const char *specFile, const char *buildRoot,
     spec = newSpec();
 
     spec->fileStack = newOpenFileInfo();
-    spec->fileStack->fileName = strdup(specFile);
+    spec->fileStack->fileName = xstrdup(specFile);
 
-    spec->specFile = strdup(specFile);
+    spec->specFile = xstrdup(specFile);
     if (buildRoot) {
        spec->gotBuildRoot = 1;
-       spec->buildRoot = strdup(buildRoot);
+       spec->buildRoot = xstrdup(buildRoot);
        addMacro(spec->macros, "buildroot", NULL, buildRoot, RMIL_SPEC);
     }
     addMacro(NULL, "_docdir", NULL, "%{_defaultdocdir}", RMIL_SPEC);
@@ -353,10 +353,10 @@ int parseSpec(Spec *specp, const char *specFile, const char *buildRoot,
     spec->force = force;
 
     if (passPhrase) {
-       spec->passPhrase = strdup(passPhrase);
+       spec->passPhrase = xstrdup(passPhrase);
     }
     if (cookie) {
-       spec->cookie = strdup(cookie);
+       spec->cookie = xstrdup(cookie);
     }
 
     {  const char *timecheck = rpmExpand("%{_timecheck}", NULL);
@@ -423,13 +423,13 @@ int parseSpec(Spec *specp, const char *specFile, const char *buildRoot,
 
        if (parsePart == PART_BUILDARCHITECTURES) {
            spec->buildArchitectureSpecs =
-               malloc(sizeof(Spec) * spec->buildArchitectureCount);
+               xmalloc(sizeof(Spec) * spec->buildArchitectureCount);
            index = 0;
            for (x = 0; x < spec->buildArchitectureCount; x++) {
                if (rpmMachineScore(RPM_MACHTABLE_BUILDARCH,
                                    spec->buildArchitectures[x])) {
                    rpmGetMachine(&saveArch, NULL);
-                   saveArch = strdup(saveArch);
+                   saveArch = xstrdup(saveArch);
                    rpmSetMachine(spec->buildArchitectures[x], NULL);
                    if (parseSpec(&(spec->buildArchitectureSpecs[index]),
                                  specFile, buildRoot, 1,
@@ -484,7 +484,7 @@ int parseSpec(Spec *specp, const char *specFile, const char *buildRoot,
        * XXX A copy of this string is embedded in headers.
        */
       if (!strcmp(os, "linux")) {
-       os = myos = strdup(os);
+       os = myos = xstrdup(os);
        *os = 'L';
       }
 
index ada50c2..b511db6 100644 (file)
@@ -94,7 +94,7 @@ Package newPackage(Spec spec)
     Package p;
     Package pp;
 
-    p = malloc(sizeof(*p));
+    p = xmalloc(sizeof(*p));
 
     p->header = headerNew();
     p->icon = NULL;
@@ -306,9 +306,9 @@ int addSource(Spec spec, Package pkg, const char *field, int tag)
     }
 
     /* Create the entry and link it in */
-    p = malloc(sizeof(struct Source));
+    p = xmalloc(sizeof(struct Source));
     p->num = num;
-    p->fullSource = strdup(field);
+    p->fullSource = xstrdup(field);
     p->source = strrchr(p->fullSource, '/');
     p->flags = flag;
     if (p->source) {
@@ -347,7 +347,7 @@ static inline struct speclines * newSl(void)
     struct speclines *sl;
     if (specedit == NULL)
        return NULL;
-    sl = malloc(sizeof(struct speclines));
+    sl = xmalloc(sizeof(struct speclines));
     sl->sl_lines = NULL;
     sl->sl_nalloc = 0;
     sl->sl_nlines = 0;
@@ -370,7 +370,7 @@ static inline struct spectags * newSt(void)
     struct spectags *st;
     if (specedit == NULL)
        return NULL;
-    st = malloc(sizeof(struct spectags));
+    st = xmalloc(sizeof(struct spectags));
     st->st_t = NULL;
     st->st_nalloc = 0;
     st->st_ntags = 0;
@@ -395,7 +395,7 @@ Spec newSpec(void)
 {
     Spec spec;
 
-    spec = (Spec)malloc(sizeof *spec);
+    spec = (Spec)xmalloc(sizeof *spec);
     
     spec->specFile = NULL;
     spec->sourceRpmName = NULL;
@@ -409,7 +409,7 @@ Spec newSpec(void)
     spec->nextline = NULL;
     spec->nextpeekc = '\0';
     spec->lineNum = 0;
-    spec->readStack = malloc(sizeof(struct ReadLevelEntry));
+    spec->readStack = xmalloc(sizeof(struct ReadLevelEntry));
     spec->readStack->next = NULL;
     spec->readStack->reading = 1;
 
@@ -518,7 +518,7 @@ void freeSpec(/*@only@*/ Spec spec)
 {
     struct OpenFileInfo *ofi;
 
-    ofi = malloc(sizeof(struct OpenFileInfo));
+    ofi = xmalloc(sizeof(struct OpenFileInfo));
     ofi->file = NULL;
     ofi->fileName = NULL;
     ofi->lineNum = 0;
index 664f4e1..68a6827 100644 (file)
@@ -367,7 +367,7 @@ AC_CHECK_HEADERS(machine/types.h)
 AC_CHECK_HEADERS(mntent.h sys/mnttab.h sys/systemcfg.h)
 AC_CHECK_HEADERS(sys/mount.h sys/mntctl.h sys/vmount.h)
 AC_CHECK_HEADERS(bzlib.h libio.h zlib.h)
-AC_CHECK_HEADERS(mcheck.h)
+AC_CHECK_HEADERS(err.h mcheck.h)
 
 dnl whether or not we should try build rpmconvert, which is used to convert
 dnl rpm databases from rpm 1.x to rpm 2.x or later.  It requires the gdbm
index 3a3405b..8d38e0d 100644 (file)
@@ -109,17 +109,17 @@ int convertDB(void) {
        if (package.fileCount) {
            /* some packages have no file lists */
 
-           fileList = malloc(sizeof(char *) * package.fileCount);
-           fileLinktoList = malloc(sizeof(char *) * package.fileCount);
-           fileMD5List = malloc(sizeof(char *) * package.fileCount);
-           fileSizeList = malloc(sizeof(int_32) * package.fileCount);
-           fileUIDList = malloc(sizeof(int_32) * package.fileCount);
-           fileGIDList = malloc(sizeof(int_32) * package.fileCount);
-           fileMtimesList = malloc(sizeof(int_32) * package.fileCount);
-           fileFlagsList = malloc(sizeof(int_32) * package.fileCount);
-           fileModesList = malloc(sizeof(int_16) * package.fileCount);
-           fileRDevsList = malloc(sizeof(int_16) * package.fileCount);
-           fileStatesList = malloc(sizeof(char) * package.fileCount);
+           fileList = xmalloc(sizeof(char *) * package.fileCount);
+           fileLinktoList = xmalloc(sizeof(char *) * package.fileCount);
+           fileMD5List = xmalloc(sizeof(char *) * package.fileCount);
+           fileSizeList = xmalloc(sizeof(int_32) * package.fileCount);
+           fileUIDList = xmalloc(sizeof(int_32) * package.fileCount);
+           fileGIDList = xmalloc(sizeof(int_32) * package.fileCount);
+           fileMtimesList = xmalloc(sizeof(int_32) * package.fileCount);
+           fileFlagsList = xmalloc(sizeof(int_32) * package.fileCount);
+           fileModesList = xmalloc(sizeof(int_16) * package.fileCount);
+           fileRDevsList = xmalloc(sizeof(int_16) * package.fileCount);
+           fileStatesList = xmalloc(sizeof(char) * package.fileCount);
 
            /* reverse the file list while we're at it */
            j = package.fileCount - 1;
index 887b432..fd61040 100644 (file)
@@ -23,8 +23,8 @@ librpm_la_SOURCES = \
        lookup.c macro.c md5.c md5sum.c \
        messages.c misc.c oldheader.c package.c problems.c query.c \
        rebuilddb.c rpmbzio.c rpmchecksig.c rpmdb.c rpmerr.c rpminstall.c \
-       rpmio.c rpmlead.c rpmrc.c signature.c stringbuf.c tagName.c tagtable.c \
-       transaction.c tread.c uninstall.c url.c verify.c
+       rpmio.c rpmlead.c rpmmalloc.c rpmrc.c signature.c stringbuf.c \
+       tagName.c tagtable.c transaction.c tread.c uninstall.c url.c verify.c
 
 tagtable.c: rpmlib.h 
        @echo '#include "system.h"' > tagtable.c
index bb81a7a..d804701 100644 (file)
@@ -237,7 +237,7 @@ static int getNextHeader(CFD_t * cfd, struct cpioHeader * chPtr)
 
     GET_NUM_FIELD(physHeader.namesize, nameSize);
 
-    chPtr->path = malloc(nameSize + 1);
+    chPtr->path = xmalloc(nameSize + 1);
     if (ourread(cfd, chPtr->path, nameSize) != nameSize) {
        free(chPtr->path);
        chPtr->path = NULL;
@@ -323,7 +323,7 @@ static int setInfo(struct cpioHeader * hdr)
 
 static int checkDirectory(char * filename)
 {
-    static char * lastDir = NULL;
+    static char * lastDir = NULL;      /* XXX memory leak */
     static int lastDirLength = 0;
     static int lastDirAlloced = 0;
     int length = strlen(filename);
@@ -347,7 +347,7 @@ static int checkDirectory(char * filename)
 
     if (lastDirAlloced < (length + 1)) {
        lastDirAlloced = length + 100;
-       lastDir = realloc(lastDir, lastDirAlloced);
+       lastDir = xrealloc(lastDir, lastDirAlloced);
     }
 
     strcpy(lastDir, buf);
@@ -522,14 +522,14 @@ static int createLinks(struct hardLink * li, /*@out@*/const char ** failedFile)
        if (!lstat(li->files[i], &sb)) {
            if (unlink(li->files[i])) {
                if (failedFile)
-                   *failedFile = strdup(li->files[i]);
+                   *failedFile = xstrdup(li->files[i]);
                return CPIOERR_UNLINK_FAILED;
            }
        }
 
        if (link(li->files[li->createdPath], li->files[i])) {
            if (failedFile)
-               *failedFile = strdup(li->files[i]);
+               *failedFile = xstrdup(li->files[i]);
            return CPIOERR_LINK_FAILED;
        }
 
@@ -603,7 +603,7 @@ int cpioInstallArchive(CFD_t *cfd, struct cpioFileMapping * mappings,
            if (map) {
                if (map->mapFlags & CPIO_MAP_PATH) {
                    free(ch.path);
-                   ch.path = strdup(map->fsPath);
+                   ch.path = xstrdup(map->fsPath);
                } 
 
                if (map->mapFlags & CPIO_MAP_MODE)
@@ -623,20 +623,20 @@ int cpioInstallArchive(CFD_t *cfd, struct cpioFileMapping * mappings,
                }
 
                if (li == NULL) {
-                   li = malloc(sizeof(*li));
+                   li = xmalloc(sizeof(*li));
                    li->inode = ch.inode;
                    li->dev = ch.dev;
                    li->nlink = ch.nlink;
                    li->linksLeft = ch.nlink;
                    li->createdPath = -1;
-                   li->files = calloc(sizeof(char *), li->nlink);
+                   li->files = xcalloc(li->nlink,(sizeof(*li->files)));
                    li->next = links;
                    links = li;
                }
 
                for (linkNum = 0; linkNum < li->nlink; linkNum++)
                    if (!li->files[linkNum]) break;
-               li->files[linkNum] = strdup(ch.path);
+               li->files[linkNum] = xstrdup(ch.path);
            }
                
            if ((ch.nlink > 1) && S_ISREG(ch.mode) && !ch.size &&
@@ -685,7 +685,7 @@ int cpioInstallArchive(CFD_t *cfd, struct cpioFileMapping * mappings,
            }
 
            if (rc && failedFile && *failedFile == NULL) {
-               *failedFile = strdup(ch.path);
+               *failedFile = xstrdup(ch.path);
 
                olderr = errno;
                unlink(ch.path);
@@ -884,7 +884,7 @@ static int writeLinkedFile(CFD_t *cfd, struct hardLink * hlink,
        if ((rc = writeFile(cfd, hlink->sb, mappings + hlink->fileMaps[i], 
                            &size, 0))) {
            if (failedFile)
-               *failedFile = strdup(mappings[hlink->fileMaps[i]].fsPath);
+               *failedFile = xstrdup(mappings[hlink->fileMaps[i]].fsPath);
            return rc;
        }
 
@@ -902,7 +902,7 @@ static int writeLinkedFile(CFD_t *cfd, struct hardLink * hlink,
        if (sizep)
            *sizep = total;
        if (failedFile) 
-           *failedFile = strdup(mappings[hlink->fileMaps[hlink->linksLeft]].fsPath);
+           *failedFile = xstrdup(mappings[hlink->fileMaps[hlink->linksLeft]].fsPath);
        return rc;
     }
     total += size;
@@ -943,7 +943,7 @@ int cpioBuildArchive(CFD_t *cfd, struct cpioFileMapping * mappings,
 
        if (rc) {
            if (failedFile)
-               *failedFile = strdup(mappings[i].fsPath);
+               *failedFile = xstrdup(mappings[i].fsPath);
            return CPIOERR_STAT_FAILED;
        }
 
@@ -953,7 +953,7 @@ int cpioBuildArchive(CFD_t *cfd, struct cpioFileMapping * mappings,
                   (hlink->dev != sb.st_dev || hlink->inode != sb.st_ino))
                hlink = hlink->next;
            if (!hlink) {
-               hlink = malloc(sizeof(*hlink));
+               hlink = xmalloc(sizeof(*hlink));
                hlink->next = hlinkList.next;
                hlinkList.next = hlink;
                hlink->sb = sb;         /* structure assignment */
@@ -961,7 +961,7 @@ int cpioBuildArchive(CFD_t *cfd, struct cpioFileMapping * mappings,
                hlink->inode = sb.st_ino;
                hlink->nlink = sb.st_nlink;
                hlink->linksLeft = sb.st_nlink;
-               hlink->fileMaps = malloc(sizeof(*hlink->fileMaps) * 
+               hlink->fileMaps = xmalloc(sizeof(*hlink->fileMaps) * 
                                                sb.st_nlink);
            }
 
@@ -984,7 +984,7 @@ int cpioBuildArchive(CFD_t *cfd, struct cpioFileMapping * mappings,
        } else {
            if ((rc = writeFile(cfd, sb, mappings + i, &size, 1))) {
                if (failedFile)
-                   *failedFile = strdup(mappings[i].fsPath);
+                   *failedFile = xstrdup(mappings[i].fsPath);
                return rc;
            }
 
index fa30c1f..b7e6576 100644 (file)
@@ -25,7 +25,7 @@ unsigned int dbiIndexRecordFileNumber(dbiIndexSet set, int recno) {
 dbiIndex * dbiOpenIndex(const char * filename, int flags, int perms, DBTYPE type) {
     dbiIndex * dbi;
         
-    dbi = malloc(sizeof(*dbi));
+    dbi = xmalloc(sizeof(*dbi));
     dbi->db = dbopen(filename, flags, perms, type, NULL);
     if (!dbi->db) {
        free(dbi);
@@ -33,7 +33,7 @@ dbiIndex * dbiOpenIndex(const char * filename, int flags, int perms, DBTYPE type
                              strerror(errno));
        return NULL;
     }
-    dbi->indexname = strdup(filename);
+    dbi->indexname = xstrdup(filename);
     return dbi;
 }
 
@@ -61,7 +61,7 @@ int dbiGetFirstKey(dbiIndex * dbi, const char ** keyp) {
        return 1;
     }
 
-    {  char *k = malloc(key.size + 1);
+    {  char *k = xmalloc(key.size + 1);
        memcpy(k, key.data, key.size);
        k[key.size] = '\0';
        *keyp = k;
@@ -88,7 +88,7 @@ int dbiSearchIndex(dbiIndex * dbi, const char * str, dbiIndexSet * set) {
        return 1;
     } 
 
-    set->recs = malloc(data.size);
+    set->recs = xmalloc(data.size);
     memcpy(set->recs, data.data, data.size);
     set->count = data.size / sizeof(dbiIndexRecord);
     return 0;
@@ -128,9 +128,9 @@ int dbiAppendIndexRecord(dbiIndexSet * set, dbiIndexRecord rec) {
     set->count++;
 
     if (set->count == 1) {
-       set->recs = malloc(set->count * sizeof(dbiIndexRecord));
+       set->recs = xmalloc(set->count * sizeof(dbiIndexRecord));
     } else {
-       set->recs = realloc(set->recs, set->count * sizeof(dbiIndexRecord));
+       set->recs = xrealloc(set->recs, set->count * sizeof(dbiIndexRecord));
     }
     set->recs[set->count - 1] = rec;
 
index 87f61e4..7fa4fd0 100644 (file)
@@ -39,7 +39,7 @@ static /*@only@*/ char *printDepend(const char * key, const char * keyEVR,
        nb += strlen(keyEVR);
     }
 
-    t = tbuf = malloc(nb + 1);
+    t = tbuf = xmalloc(nb + 1);
     if (key)
        while(*key)     *t++ = *key++;
     if (keyFlags) {
@@ -58,7 +58,7 @@ static /*@only@*/ char *printDepend(const char * key, const char * keyEVR,
 
 static /*@only@*/ char *buildEVR(int_32 *e, const char *v, const char *r)
 {
-    char *pEVR = malloc(21 + strlen(v) + 1 + strlen(r) + 1);
+    char *pEVR = xmalloc(21 + strlen(v) + 1 + strlen(r) + 1);
     *pEVR = '\0';
     if (e)
        sprintf(pEVR, "%d:", *e);
@@ -85,13 +85,9 @@ static void alFreeIndex(struct availableList * al)
 
 static void alCreate(/*@out@*/struct availableList * al)
 {
-    size_t nb;
-
     al->alloced = 5;
     al->size = 0;
-    nb = sizeof(*al->list) * al->alloced;
-    al->list = malloc(nb);
-    memset(al->list, 0, nb);
+    al->list = xcalloc(al->alloced, sizeof(*al->list));
 
     al->index.index = NULL;
     al->index.size = 0;
@@ -137,11 +133,11 @@ static /*@exposed@*/ struct availablePackage * alAddPackage(struct availableList
 
     if (al->size == al->alloced) {
        al->alloced += 5;
-       al->list = realloc(al->list, sizeof(*al->list) * al->alloced);
+       al->list = xrealloc(al->list, sizeof(*al->list) * al->alloced);
     }
 
     p = al->list + al->size++;
-    p->h = headerLink(h);
+    p->h = headerLink(h);      /* XXX reference held by transaction set */
 
     headerNVR(p->h, &p->name, &p->version, &p->release);
 
@@ -182,11 +178,11 @@ static /*@exposed@*/ struct availablePackage * alAddPackage(struct availableList
 
     if (relocs) {
        for (i = 0, r = relocs; r->oldPath || r->newPath; i++, r++);
-       p->relocs = malloc(sizeof(*p->relocs) * (i + 1));
+       p->relocs = xmalloc(sizeof(*p->relocs) * (i + 1));
 
        for (i = 0, r = relocs; r->oldPath || r->newPath; i++, r++) {
-           p->relocs[i].oldPath = r->oldPath ? strdup(r->oldPath) : NULL;
-           p->relocs[i].newPath = r->newPath ? strdup(r->newPath) : NULL;
+           p->relocs[i].oldPath = r->oldPath ? xstrdup(r->oldPath) : NULL;
+           p->relocs[i].newPath = r->newPath ? xstrdup(r->newPath) : NULL;
        }
        p->relocs[i].oldPath = NULL;
        p->relocs[i].newPath = NULL;
@@ -223,9 +219,7 @@ static void alMakeIndex(struct availableList * al)
     }
 
     if (ai->size) {
-       size_t nb = sizeof(*ai->index) * ai->size;
-       ai->index = malloc(nb);
-       memset(ai->index, 0, nb);
+       ai->index = xcalloc(ai->size, sizeof(*ai->index));
 
        k = 0;
        for (i = 0; i < al->size; i++) {
@@ -329,9 +323,9 @@ static int rangesOverlap(const char *AName, const char *AEVR, int AFlags,
     }
 
     /* Both AEVR and BEVR exist. */
-    aEVR = strdup(AEVR);
+    aEVR = xstrdup(AEVR);
     parseEVR(aEVR, &aE, &aV, &aR);
-    bEVR = strdup(BEVR);
+    bEVR = xstrdup(BEVR);
     parseEVR(bEVR, &bE, &bV, &bR);
 
     /* Compare {A,B} [epoch:]version[-release] */
@@ -468,18 +462,16 @@ rpmTransactionSet rpmtransCreateSet(rpmdb db, const char * root)
 {
     rpmTransactionSet rpmdep;
     int rootLength;
-    size_t nb;
 
     if (!root) root = "";
 
-    rpmdep = malloc(sizeof(*rpmdep));
+    rpmdep = xmalloc(sizeof(*rpmdep));
     rpmdep->db = db;
     rpmdep->scriptFd = NULL;
     rpmdep->numRemovedPackages = 0;
     rpmdep->allocedRemovedPackages = 5;
-    nb = sizeof(*rpmdep->removedPackages) * rpmdep->allocedRemovedPackages;
-    rpmdep->removedPackages = malloc(nb);
-    memset(rpmdep->removedPackages, 0, nb);
+    rpmdep->removedPackages = xcalloc(rpmdep->allocedRemovedPackages,
+                       sizeof(*rpmdep->removedPackages));
 
     /* This canonicalizes the root */
     rootLength = strlen(root);
@@ -493,16 +485,14 @@ rpmTransactionSet rpmtransCreateSet(rpmdb db, const char * root)
        root = newRootdir;
     }
 
-    rpmdep->root = strdup(root);
+    rpmdep->root = xstrdup(root);
 
     alCreate(&rpmdep->addedPackages);
     alCreate(&rpmdep->availablePackages);
 
     rpmdep->orderAlloced = 5;
     rpmdep->orderCount = 0;
-    nb = sizeof(*rpmdep->order) * rpmdep->orderAlloced;
-    rpmdep->order = malloc(nb);
-    memset(rpmdep->order, 0, nb);
+    rpmdep->order = xcalloc(rpmdep->orderAlloced, sizeof(*rpmdep->order));
 
     return rpmdep;
 }
@@ -511,7 +501,7 @@ static void removePackage(rpmTransactionSet rpmdep, int dboffset, int depends)
 {
     if (rpmdep->numRemovedPackages == rpmdep->allocedRemovedPackages) {
        rpmdep->allocedRemovedPackages += 5;
-       rpmdep->removedPackages = realloc(rpmdep->removedPackages,
+       rpmdep->removedPackages = xrealloc(rpmdep->removedPackages,
                sizeof(int *) * rpmdep->allocedRemovedPackages);
     }
 
@@ -519,7 +509,7 @@ static void removePackage(rpmTransactionSet rpmdep, int dboffset, int depends)
 
     if (rpmdep->orderCount == rpmdep->orderAlloced) {
        rpmdep->orderAlloced += 5;
-       rpmdep->order = realloc(rpmdep->order,
+       rpmdep->order = xrealloc(rpmdep->order,
                sizeof(*rpmdep->order) * rpmdep->orderAlloced);
     }
 
@@ -557,7 +547,7 @@ int rpmtransAddPackage(rpmTransactionSet rpmdep, Header h, FD_t fd,
 
     if (rpmdep->orderCount == rpmdep->orderAlloced) {
        rpmdep->orderAlloced += 5;
-       rpmdep->order = realloc(rpmdep->order,
+       rpmdep->order = xrealloc(rpmdep->order,
                sizeof(*rpmdep->order) * rpmdep->orderAlloced);
     }
     rpmdep->order[rpmdep->orderCount].type = TR_ADDED;
@@ -872,15 +862,15 @@ static int checkPackageDeps(rpmTransactionSet rpmdep, struct problemsSet * psp,
 
            if (psp->num == psp->alloced) {
                psp->alloced += 5;
-               psp->problems = realloc(psp->problems, sizeof(*psp->problems) *
+               psp->problems = xrealloc(psp->problems, sizeof(*psp->problems) *
                            psp->alloced);
            }
            psp->problems[psp->num].byHeader = headerLink(h);
-           psp->problems[psp->num].byName = strdup(name);
-           psp->problems[psp->num].byVersion = strdup(version);
-           psp->problems[psp->num].byRelease = strdup(release);
-           psp->problems[psp->num].needsName = strdup(requires[i]);
-           psp->problems[psp->num].needsVersion = strdup(requiresEVR[i]);
+           psp->problems[psp->num].byName = xstrdup(name);
+           psp->problems[psp->num].byVersion = xstrdup(version);
+           psp->problems[psp->num].byRelease = xstrdup(release);
+           psp->problems[psp->num].needsName = xstrdup(requires[i]);
+           psp->problems[psp->num].needsVersion = xstrdup(requiresEVR[i]);
            psp->problems[psp->num].needsFlags = requireFlags[i];
            psp->problems[psp->num].sense = RPMDEP_SENSE_REQUIRES;
 
@@ -934,15 +924,15 @@ static int checkPackageDeps(rpmTransactionSet rpmdep, struct problemsSet * psp,
 
            if (psp->num == psp->alloced) {
                psp->alloced += 5;
-               psp->problems = realloc(psp->problems, sizeof(*psp->problems) *
+               psp->problems = xrealloc(psp->problems, sizeof(*psp->problems) *
                            psp->alloced);
            }
            psp->problems[psp->num].byHeader = headerLink(h);
-           psp->problems[psp->num].byName = strdup(name);
-           psp->problems[psp->num].byVersion = strdup(version);
-           psp->problems[psp->num].byRelease = strdup(release);
-           psp->problems[psp->num].needsName = strdup(conflicts[i]);
-           psp->problems[psp->num].needsVersion = strdup(conflictsEVR[i]);
+           psp->problems[psp->num].byName = xstrdup(name);
+           psp->problems[psp->num].byVersion = xstrdup(version);
+           psp->problems[psp->num].byRelease = xstrdup(release);
+           psp->problems[psp->num].needsName = xstrdup(conflicts[i]);
+           psp->problems[psp->num].needsVersion = xstrdup(conflictsEVR[i]);
            psp->problems[psp->num].needsFlags = conflictFlags[i];
            psp->problems[psp->num].sense = RPMDEP_SENSE_CONFLICTS;
            psp->problems[psp->num].suggestedPackage = NULL;
@@ -1181,7 +1171,7 @@ int rpmdepOrder(rpmTransactionSet rpmdep)
        with removes for upgrades immediately follwing the installation of
        the new package. This would be easier if we could sort the
        addedPackages array, but we store indexes into it in various places. */
-    orderList = malloc(sizeof(*orderList) * rpmdep->addedPackages.size);
+    orderList = xmalloc(sizeof(*orderList) * rpmdep->addedPackages.size);
     for (i = 0, j = 0; i < rpmdep->orderCount; i++) {
        if (rpmdep->order[i].type == TR_ADDED) {
            orderList[j].alIndex = rpmdep->order[i].u.addedIndex;
@@ -1194,7 +1184,8 @@ int rpmdepOrder(rpmTransactionSet rpmdep)
     qsort(orderList, rpmdep->addedPackages.size, sizeof(*orderList),
          orderListIndexCmp);
 
-    newOrder = malloc(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,
@@ -1239,13 +1230,10 @@ int rpmdepCheck(rpmTransactionSet rpmdep,
     int rc;
     Header h = NULL;
     struct problemsSet ps;
-    size_t nb;
 
     ps.alloced = 5;
     ps.num = 0;
-    nb = sizeof(struct rpmDependencyConflict) * ps.alloced;
-    ps.problems = malloc(nb);
-    memset(ps.problems, 0, nb);
+    ps.problems = xcalloc(ps.alloced, sizeof(struct rpmDependencyConflict));
 
     *conflicts = NULL;
     *numConflicts = 0;
@@ -1345,7 +1333,9 @@ int rpmdepCheck(rpmTransactionSet rpmdep,
     return 0;
 
 exit:
-    if (h)             headerFree(h);
+    if (h) {
+       headerFree(h);
+    }
     if (ps.problems)   free(ps.problems);
     return 1;
 }
index c82032c..f66c7d6 100644 (file)
@@ -107,6 +107,7 @@ faFile faOpen(const char * path, int flags, int perms)
        fas.fileSize = faLseek(&fas, 0, SEEK_CUR);
     }
 
+    /* XXX xmalloc is inappopriate here */
     if ((fa = malloc(sizeof(*fa))) != NULL) {
        fa->fd = fas.fd;
        fa->readOnly = fas.readOnly;
index 0ce4a27..f88a488 100644 (file)
@@ -4,7 +4,7 @@
 
 static char * permsString(int mode)
 {
-    char * perms = malloc(11);
+    char * perms = xmalloc(11);
 
     strcpy(perms, "-----------");
    
@@ -62,12 +62,12 @@ static char * triggertypeFormat(int_32 type, const void * data,
     char * val;
 
     if (type != RPM_INT32_TYPE) {
-       val = malloc(20);
+       val = xmalloc(20);
        strcpy(val, _("(not a number)"));
     } else if (*item & RPMSENSE_TRIGGERIN) {
-       val = strdup("in");
+       val = xstrdup("in");
     } else {
-       val = strdup("un");
+       val = xstrdup("un");
     }
 
     return val;
@@ -80,10 +80,10 @@ static char * permsFormat(int_32 type, const void * data,
     char * buf;
 
     if (type != RPM_INT32_TYPE) {
-       val = malloc(20);
+       val = xmalloc(20);
        strcpy(val, _("(not a number)"));
     } else {
-       val = malloc(15 + padding);
+       val = xmalloc(15 + padding);
        strcat(formatPrefix, "s");
        buf = permsString(*((int_32 *) data));
        sprintf(val, formatPrefix, buf);
@@ -101,7 +101,7 @@ static char * fflagsFormat(int_32 type, const void * data,
     int anint = *((int_32 *) data);
 
     if (type != RPM_INT32_TYPE) {
-       val = malloc(20);
+       val = xmalloc(20);
        strcpy(val, _("(not a number)"));
     } else {
        buf[0] = '\0';
@@ -118,7 +118,7 @@ static char * fflagsFormat(int_32 type, const void * data,
        if (anint & RPMFILE_GHOST)
            strcat(buf, "g");
 
-       val = malloc(5 + padding);
+       val = xmalloc(5 + padding);
        strcat(formatPrefix, "s");
        sprintf(val, formatPrefix, buf);
     }
@@ -134,7 +134,7 @@ static char * depflagsFormat(int_32 type, const void * data,
     int anint = *((int_32 *) data);
 
     if (type != RPM_INT32_TYPE) {
-       val = malloc(20);
+       val = xmalloc(20);
        strcpy(val, _("(not a number)"));
     } else {
        buf[0] = '\0';
@@ -146,7 +146,7 @@ static char * depflagsFormat(int_32 type, const void * data,
        if (anint & RPMSENSE_EQUAL)
            strcat(buf, "=");
 
-       val = malloc(5 + padding);
+       val = xmalloc(5 + padding);
        strcat(formatPrefix, "s");
        sprintf(val, formatPrefix, buf);
     }
@@ -181,7 +181,7 @@ static int instprefixTag(Header h, int_32 * type, void ** data, int_32 * count,
        return 0;
     } else if (headerGetEntry(h, RPMTAG_INSTPREFIXES, NULL, (void **) &array, 
                              count)) {
-       *((char **) data) = strdup(array[0]);
+       *((char **) data) = xstrdup(array[0]);
        *freeData = 1;
        *type = RPM_STRING_TYPE;
        free(array);
@@ -216,8 +216,7 @@ static int fssizesTag(Header h, int_32 * type, void ** data, int_32 * count,
     *freeData = 1;
 
     if (filenames == NULL) {
-       usages = malloc(sizeof(usages) * (*count));
-       memset(usages, 0, sizeof(usages) * (*count));
+       usages = xcalloc((*count), sizeof(usages));
        *data = usages;
 
        return 0;
@@ -256,17 +255,16 @@ static int triggercondsTag(Header h, /*@out@*/int_32 * type, /*@out@*/void ** da
     free(s);
 
     *freeData = 1;
-    *data = conds = malloc(sizeof(char * ) * numScripts);
+    *data = conds = xmalloc(sizeof(char * ) * numScripts);
     *count = numScripts;
     *type = RPM_STRING_ARRAY_TYPE;
     for (i = 0; i < numScripts; i++) {
-       chptr = malloc(1);
-       *chptr = '\0';
+       chptr = xstrdup("");
 
        for (j = 0; j < numNames; j++) {
            if (indices[j] != i) continue;
 
-           item = malloc(strlen(names[j]) + strlen(versions[j]) + 20);
+           item = xmalloc(strlen(names[j]) + strlen(versions[j]) + 20);
            if (flags[j] & RPMSENSE_SENSEMASK) {
                buf[0] = '%', buf[1] = '\0';
                flagsStr = depflagsFormat(RPM_INT32_TYPE, flags, buf,
@@ -277,7 +275,7 @@ static int triggercondsTag(Header h, /*@out@*/int_32 * type, /*@out@*/void ** da
                strcpy(item, names[j]);
            }
 
-           chptr = realloc(chptr, strlen(chptr) + strlen(item) + 5);
+           chptr = xrealloc(chptr, strlen(chptr) + strlen(item) + 5);
            if (*chptr) strcat(chptr, ", ");
            strcat(chptr, item);
            free(item);
@@ -312,7 +310,7 @@ static int triggertypeTag(Header h, int_32 * type, /*@out@*/void ** data,
     free(s);
 
     *freeData = 1;
-    *data = conds = malloc(sizeof(char * ) * numScripts);
+    *data = conds = xmalloc(sizeof(char * ) * numScripts);
     *count = numScripts;
     *type = RPM_STRING_ARRAY_TYPE;
     for (i = 0; i < numScripts; i++) {
@@ -320,11 +318,11 @@ static int triggertypeTag(Header h, int_32 * type, /*@out@*/void ** data,
            if (indices[j] != i) continue;
 
            if (flags[j] & RPMSENSE_TRIGGERIN)
-               conds[i] = strdup("in");
+               conds[i] = xstrdup("in");
            else if (flags[j] & RPMSENSE_TRIGGERUN)
-               conds[i] = strdup("un");
+               conds[i] = xstrdup("un");
            else
-               conds[i] = strdup("postun");
+               conds[i] = xstrdup("postun");
            break;
        }
     }
index 95f055f..2c34984 100644 (file)
@@ -52,7 +52,7 @@ static fingerPrint doLookup(const char * fullName, int scareMemory,
                if (scareMemory)
                    fp.basename = chptr1;
                else
-                   fp.basename = strdup(chptr1);
+                   fp.basename = xstrdup(chptr1);
                fp.ino = cache->ino;
                fp.dev = cache->dev;
                return fp;
@@ -96,7 +96,7 @@ static fingerPrint doLookup(const char * fullName, int scareMemory,
            if (scareMemory)
                fp.basename = chptr1;
            else
-               fp.basename = strdup(chptr1);
+               fp.basename = xstrdup(chptr1);
            fp.ino = sb.st_ino;
            fp.dev = sb.st_dev;
 
index 777c5cf..e4b3e5b 100644 (file)
--- a/lib/fs.c
+++ b/lib/fs.c
@@ -59,13 +59,13 @@ static int getFilesystemList(void)
 
     numFilesystems = num;
 
-    filesystems = malloc(sizeof(*filesystems) * (numFilesystems + 1));
-    fsnames = malloc(sizeof(char *) * (numFilesystems + 1));
+    filesystems = xcalloc((numFilesystems + 1), sizeof(*filesystems));
+    fsnames = xcalloc((numFilesystems + 1), sizeof(char *));
     
     for (vm = buf, i = 0; i < num; i++) {
        char *fsn;
        fsnameLength = vm->vmt_data[VMT_STUB].vmt_size;
-       fsn = malloc(fsnameLength + 1);
+       fsn = xmalloc(fsnameLength + 1);
        strncpy(fsn, (char *)vm + vm->vmt_data[VMT_STUB].vmt_off, 
                fsnameLength);
 
@@ -124,8 +124,7 @@ static int getFilesystemList(void)
        getmntinfo_r(&mounts, flags, &mntCount, &bufSize);
 #   endif
 
-    filesystems = malloc(sizeof(*filesystems) * (numAlloced + 1));
-    memset(filesystems, 0, sizeof(*filesystems) * (numAlloced + 1));
+    filesystems = xcalloc((numAlloced + 1), sizeof(*filesystems));
 
     while (1) {
 #      if GETMNTENT_ONE
@@ -157,12 +156,12 @@ static int getFilesystemList(void)
 
        if (num == numAlloced) {
            numAlloced += 10;
-           filesystems = realloc(filesystems, 
+           filesystems = xrealloc(filesystems, 
                                  sizeof(*filesystems) * (numAlloced + 1));
        }
 
        filesystems[num].dev = sb.st_dev;
-       filesystems[num].mntPoint = strdup(mntdir);
+       filesystems[num].mntPoint = xstrdup(mntdir);
        num++;
     }
 
@@ -175,7 +174,7 @@ static int getFilesystemList(void)
     filesystems[num].dev = 0;
     filesystems[num].mntPoint = NULL;
 
-    fsnames = malloc(sizeof(*fsnames) * (num + 1));
+    fsnames = xcalloc((num + 1), sizeof(*fsnames));
     for (i = 0; i < num; i++)
        fsnames[i] = filesystems[i].mntPoint;
     fsnames[num] = NULL;
@@ -216,7 +215,7 @@ int rpmGetFilesystemUsage(const char ** fileList, int_32 * fssizes, int numFiles
        if (getFilesystemList())
            return 1;
 
-    usages = calloc(numFilesystems, sizeof(usages));
+    usages = xcalloc(numFilesystems, sizeof(usages));
 
     sourceDir = rpmGetPath("", "/%{_sourcedir}", NULL);
 
index 8ee66ca..8dc7339 100644 (file)
@@ -61,9 +61,9 @@ hashTable htCreate(int numBuckets, int keySize, hashFunctionType fn,
 {
     hashTable ht;
 
-    ht = malloc(sizeof(*ht));
+    ht = xmalloc(sizeof(*ht));
     ht->numBuckets = numBuckets;
-    ht->buckets = calloc(sizeof(*ht->buckets), numBuckets);
+    ht->buckets = xcalloc(numBuckets, sizeof(*ht->buckets));
     ht->keySize = keySize;
     ht->fn = fn;
     ht->eq = eq;
@@ -83,9 +83,9 @@ void htAddEntry(hashTable ht, const void * key, const void * data)
        b = b->next;
    
     if (!b) {
-       b = malloc(sizeof(*b));
+       b = xmalloc(sizeof(*b));
        if (ht->keySize) {
-           char *k = malloc(ht->keySize);
+           char *k = xmalloc(ht->keySize);
            memcpy(k, key, ht->keySize);
            b->key = k;
        } else {
@@ -97,7 +97,7 @@ void htAddEntry(hashTable ht, const void * key, const void * data)
        ht->buckets[hash] = b;
     }
 
-    b->data = realloc(b->data, sizeof(*b->data) * (b->dataCount + 1));
+    b->data = xrealloc(b->data, sizeof(*b->data) * (b->dataCount + 1));
     b->data[b->dataCount++] = data;
 }
 
index 34ba7d8..d27414b 100644 (file)
@@ -132,10 +132,10 @@ static void copyEntry(struct indexEntry * entry, /*@out@*/int_32 *type,
        i = entry->info.count;
        tableSize = i * sizeof(char *);
        if (minimizeMemory) {
-           ptrEntry = *p = malloc(tableSize);
+           ptrEntry = *p = xmalloc(tableSize);
            chptr = entry->data;
        } else {
-           ptrEntry = *p = malloc(tableSize + entry->length);
+           ptrEntry = *p = xmalloc(tableSize + entry->length);
            chptr = ((char *) *p) + tableSize;
            memcpy(chptr, entry->data, entry->length);
        }
@@ -220,7 +220,7 @@ struct headerIteratorS {
 
 HeaderIterator headerInitIterator(Header h)
 {
-    HeaderIterator hi = malloc(sizeof(struct headerIteratorS));
+    HeaderIterator hi = xmalloc(sizeof(struct headerIteratorS));
 
     headerSort(h);
 
@@ -318,7 +318,7 @@ Header headerLoad(void *pv)
     const char * dataStart;
     struct entryInfo * pe;
     struct indexEntry * entry; 
-    struct headerToken *h = malloc(sizeof(struct headerToken));
+    struct headerToken *h = xmalloc(sizeof(struct headerToken));
     const char * src;
     char * dst;
     int i;
@@ -333,7 +333,7 @@ Header headerLoad(void *pv)
 
     h->indexAlloced = il;
     h->indexUsed = il;
-    h->index = malloc(il * sizeof(struct indexEntry));
+    h->index = xmalloc(sizeof(struct indexEntry) * il);
     h->usageCount = 1;
 
     /* This assumes you only headerLoad() something you headerUnload()-ed */
@@ -354,7 +354,7 @@ Header headerLoad(void *pv)
        src = dataStart + htonl(pe->offset);
        entry->length = dataLength(entry->info.type, src, 
                                   entry->info.count, 1);
-       entry->data = dst = malloc(entry->length);
+       entry->data = dst = xmalloc(entry->length);
 
        /* copy data w/ endian conversions */
        switch (entry->info.type) {
@@ -399,7 +399,7 @@ static void *doHeaderUnload(Header h, /*@out@*/int * lengthPtr)
     headerSort(h);
 
     *lengthPtr = headerSizeof(h, 0);
-    pi = p = malloc(*lengthPtr);
+    pi = p = xmalloc(*lengthPtr);
 
     *pi++ = htonl(h->indexUsed);
 
@@ -546,7 +546,7 @@ Header headerRead(FD_t fd, int magicp)
     if (totalSize > (32*1024*1024))
        return NULL;
 
-    dataBlock = p = malloc(totalSize);
+    dataBlock = p = xmalloc(totalSize);
     *p++ = htonl(il);
     *p++ = htonl(dl);
 
@@ -630,7 +630,7 @@ Header headerGzRead(FD_t fd, int magicp)
     totalSize = sizeof(int_32) + sizeof(int_32) + 
                (il * sizeof(struct entryInfo)) + dl;
 
-    block = p = malloc(totalSize);
+    block = p = xmalloc(totalSize);
     *p++ = htonl(il);
     *p++ = htonl(dl);
 
@@ -991,10 +991,10 @@ int headerGetEntry(Header h, int_32 tag, int_32 * type, void **p, int_32 * c)
 
 Header headerNew()
 {
-    Header h = malloc(sizeof(struct headerToken));
+    Header h = xmalloc(sizeof(struct headerToken));
 
-    h->index = malloc(INDEX_MALLOC_SIZE * sizeof(struct indexEntry));
     h->indexAlloced = INDEX_MALLOC_SIZE;
+    h->index = xcalloc(h->indexAlloced, sizeof(struct indexEntry));
     h->indexUsed = 0;
 
     h->sorted = 0;
@@ -1021,6 +1021,11 @@ Header headerLink(Header h)
     return h;
 }
 
+int headerUsageCount(Header h)
+{
+    return h->usageCount;
+}
+
 unsigned int headerSizeof(Header h, int magicp)
 {
     unsigned int size;
@@ -1086,7 +1091,7 @@ static void * grabData(int_32 type, /*@out@*/const void * p, int_32 c, int * len
     void * data;
 
     length = dataLength(type, p, c, 0);
-    data = malloc(length);
+    data = xmalloc(length);
 
     copyData(type, data, p, c, length);
 
@@ -1115,7 +1120,7 @@ int headerAddEntry(Header h, int_32 tag, int_32 type, const void *p, int_32 c)
     /* Allocate more index space if necessary */
     if (h->indexUsed == h->indexAlloced) {
        h->indexAlloced += INDEX_MALLOC_SIZE;
-       h->index = realloc(h->index,
+       h->index = xrealloc(h->index,
                        h->indexAlloced * sizeof(struct indexEntry));
     }
 
@@ -1142,7 +1147,7 @@ headerGetLangs(Header h)
     if (!headerGetRawEntry(h, HEADER_I18NTABLE, &type, (void **)&s, &count))
        return NULL;
 
-    if ((table = (char **)calloc((count+1), sizeof(char *))) == NULL)
+    if ((table = (char **)xcalloc((count+1), sizeof(char *))) == NULL)
        return NULL;
 
     for (i = 0, e = *s; i < count > 0; i++, e += strlen(e)+1) {
@@ -1195,7 +1200,7 @@ int headerAddI18NString(Header h, int_32 tag, char * string, char * lang)
 
     if (langNum >= table->info.count) {
        length = strlen(lang) + 1;
-       table->data = realloc(table->data, table->length + length);
+       table->data = xrealloc(table->data, table->length + length);
        memcpy(((char *)table->data) + table->length, lang, length);
        table->length += length;
        table->info.count++;
@@ -1212,7 +1217,7 @@ int headerAddI18NString(Header h, int_32 tag, char * string, char * lang)
        ghosts = langNum - entry->info.count;
        
        length = strlen(string) + 1 + ghosts;
-       entry->data = realloc(entry->data, entry->length + length);
+       entry->data = xrealloc(entry->data, entry->length + length);
 
        memset(((char *)entry->data) + entry->length, '\0', ghosts);
        strcpy(((char *)entry->data) + entry->length + ghosts, string);
@@ -1238,7 +1243,7 @@ int headerAddI18NString(Header h, int_32 tag, char * string, char * lang)
        sn = strlen(string) + 1;
        en = (ee-e);
        length = bn + sn + en;
-       t = buf = malloc(length);
+       t = buf = xmalloc(length);
 
        /* Copy values into new storage */
        memcpy(t, b, bn);
@@ -1315,7 +1320,7 @@ int headerAppendEntry(Header h, int_32 tag, int_32 type, void * p, int_32 c)
 
     length = dataLength(type, p, c, 0);
 
-    entry->data = realloc(entry->data, entry->length + length);
+    entry->data = xrealloc(entry->data, entry->length + length);
     copyData(type, ((char *) entry->data) + entry->length, p, c, length);
 
     entry->length += length;
@@ -1462,7 +1467,7 @@ static int parseFormat(char * str, const struct headerTagTableEntry * tags,
        if (*chptr == '%') numTokens++;
     numTokens = numTokens * 2 + 1;
 
-    format = calloc(sizeof(*format), numTokens);
+    format = xcalloc(numTokens, sizeof(*format));
     if (endPtr) *endPtr = NULL;
 
     dst = start = str;
@@ -1700,7 +1705,7 @@ static int parseExpression(struct sprintfToken * token, char * str,
     }
 
     if (*chptr == '|') {
-       parseFormat(strdup(""), tags, extensions, &token->u.cond.elseFormat, 
+       parseFormat(xstrdup(""), tags, extensions, &token->u.cond.elseFormat, 
                        &token->u.cond.numElseTokens, &end, PARSER_IN_EXPR, 
                        error);
     } else {
@@ -1845,7 +1850,7 @@ static char * formatValue(struct sprintfTag * tag, Header h,
            strcat(buf, "s");
 
            len = strlen(strarray[element]) + tag->pad + 20;
-           val = malloc(len);
+           val = xmalloc(len);
            sprintf(val, buf, strarray[element]);
        }
 
@@ -1862,7 +1867,7 @@ static char * formatValue(struct sprintfTag * tag, Header h,
            strcat(buf, "s");
 
            len = strlen(data) + tag->pad + 20;
-           val = malloc(len);
+           val = xmalloc(len);
            sprintf(val, buf, data);
        }
        break;
@@ -1886,13 +1891,13 @@ static char * formatValue(struct sprintfTag * tag, Header h,
        if (!val) {
            strcat(buf, "d");
            len = 10 + tag->pad + 20;
-           val = malloc(len);
+           val = xmalloc(len);
            sprintf(val, buf, intVal);
        }
        break;
 
       default:
-       val = malloc(20);
+       val = xmalloc(20);
        strcpy(val, _("(unknown type)"));
        break;
     }
@@ -1921,7 +1926,7 @@ static char * singleSprintf(Header h, struct sprintfToken * token,
        break;
 
       case PTOK_STRING:
-       val = malloc(token->u.string.len + 1);
+       val = xmalloc(token->u.string.len + 1);
        strcpy(val, token->u.string.string);
        break;
 
@@ -1941,7 +1946,7 @@ static char * singleSprintf(Header h, struct sprintfToken * token,
        }
 
        alloced = condNumFormats * 20;
-       val = malloc(alloced ? alloced : 1);
+       val = xmalloc(alloced ? alloced : 1);
        *val = '\0';
        len = 0;
 
@@ -1951,7 +1956,7 @@ static char * singleSprintf(Header h, struct sprintfToken * token,
            thisItemLen = strlen(thisItem);
            if ((thisItemLen + len) >= alloced) {
                alloced = (thisItemLen + len) + 200;
-               val = realloc(val, alloced);    
+               val = xrealloc(val, alloced);   
            }
            strcat(val, thisItem);
            len += thisItemLen;
@@ -1983,11 +1988,11 @@ static char * singleSprintf(Header h, struct sprintfToken * token,
        }
 
        if (numElements == -1) {
-           val = malloc(20);
+           val = xmalloc(20);
            strcpy(val, "(none)");      /* XXX i18n? NO!, sez; gafton */
        } else {
            alloced = numElements * token->u.array.numTokens * 20;
-           val = malloc(alloced);
+           val = xmalloc(alloced);
            *val = '\0';
            len = 0;
 
@@ -1998,7 +2003,7 @@ static char * singleSprintf(Header h, struct sprintfToken * token,
                    thisItemLen = strlen(thisItem);
                    if ((thisItemLen + len) >= alloced) {
                        alloced = (thisItemLen + len) + 200;
-                       val = realloc(val, alloced);    
+                       val = xrealloc(val, alloced);   
                    }
                    strcat(val, thisItem);
                    len += thisItemLen;
@@ -2027,7 +2032,7 @@ static struct extensionCache * allocateExtensionCache(
            ext++;
     }
 
-    return calloc(i, sizeof(struct extensionCache));
+    return xcalloc(i, sizeof(struct extensionCache));
 }
 
 static void freeExtensionCache(const struct headerSprintfExtension * extensions,
@@ -2065,7 +2070,7 @@ char * headerSprintf(Header h, const char * origFmt,
     struct extensionCache * extCache;
  
     /*fmtString = escapeString(origFmt);*/
-    fmtString = strdup(origFmt);
+    fmtString = xstrdup(origFmt);
    
     if (parseFormat(fmtString, tags, extensions, &format, &numTokens, 
                    NULL, PARSER_BEGIN, error)) {
@@ -2077,7 +2082,7 @@ char * headerSprintf(Header h, const char * origFmt,
 
     answerAlloced = 1024;
     answerLength = 0;
-    answer = malloc(answerAlloced);
+    answer = xmalloc(answerAlloced);
     *answer = '\0';
 
     for (i = 0; i < numTokens; i++) {
@@ -2087,7 +2092,7 @@ char * headerSprintf(Header h, const char * origFmt,
            if ((answerLength + pieceLength) >= answerAlloced) {
                while ((answerLength + pieceLength) >= answerAlloced) 
                    answerAlloced += 1024;
-               answer = realloc(answer, answerAlloced);
+               answer = xrealloc(answer, answerAlloced);
            }
 
            strcat(answer, piece);
@@ -2109,10 +2114,10 @@ static char * octalFormat(int_32 type, const void * data,
     char * val;
 
     if (type != RPM_INT32_TYPE) {
-       val = malloc(20);
+       val = xmalloc(20);
        strcpy(val, _("(not a number)"));
     } else {
-       val = malloc(20 + padding);
+       val = xmalloc(20 + padding);
        strcat(formatPrefix, "o");
        sprintf(val, formatPrefix, *((int_32 *) data));
     }
@@ -2126,10 +2131,10 @@ static char * hexFormat(int_32 type, const void * data,
     char * val;
 
     if (type != RPM_INT32_TYPE) {
-       val = malloc(20);
+       val = xmalloc(20);
        strcpy(val, _("(not a number)"));
     } else {
-       val = malloc(20 + padding);
+       val = xmalloc(20 + padding);
        strcat(formatPrefix, "x");
        sprintf(val, formatPrefix, *((int_32 *) data));
     }
@@ -2146,10 +2151,10 @@ static char * realDateFormat(int_32 type, const void * data,
     char buf[50];
 
     if (type != RPM_INT32_TYPE) {
-       val = malloc(20);
+       val = xmalloc(20);
        strcpy(val, _("(not a number)"));
     } else {
-       val = malloc(50 + padding);
+       val = xmalloc(50 + padding);
        strcat(formatPrefix, "s");
 
        /* this is important if sizeof(int_32) ! sizeof(time_t) */
@@ -2182,7 +2187,7 @@ static char * shescapeFormat(int_32 type, const void * data,
     char * result, * dst, * src, * buf;
 
     if (type == RPM_INT32_TYPE) {
-       result = malloc(padding + 20);
+       result = xmalloc(padding + 20);
        strcat(formatPrefix, "d");
        sprintf(result, formatPrefix, *((int_32 *) data));
     } else {
@@ -2190,7 +2195,7 @@ static char * shescapeFormat(int_32 type, const void * data,
        strcat(formatPrefix, "s");
        sprintf(buf, formatPrefix, data);
 
-       result = dst = malloc(strlen(buf) * 4 + 3);
+       result = dst = xmalloc(strlen(buf) * 4 + 3);
        *dst++ = '\'';
        for (src = buf; *src; src++) {
            if (*src == '\'') {
index fa9b181..bdae6a5 100644 (file)
@@ -157,6 +157,7 @@ void headerFreeIterator(/*@only@*/ HeaderIterator iter);
 Header headerCopy(Header h);
 void headerSort(Header h);
 Header headerLink(Header h);
+int headerUsageCount(Header h);
 
 void headerCopyTags(Header headerFrom, Header headerTo, int_32 *tagstocopy);
 
index bfa3779..48fa0ec 100644 (file)
@@ -75,7 +75,7 @@ static int rpmInstallLoadMacros(Header h)
 
 static /*@only@*/ struct fileMemory *newFileMemory(void)
 {
-    struct fileMemory *fileMem = malloc(sizeof(*fileMem));
+    struct fileMemory *fileMem = xmalloc(sizeof(*fileMem));
     fileMem->files = NULL;
     fileMem->names = NULL;
     fileMem->cpioNames = NULL;
@@ -118,7 +118,7 @@ static int assembleFileList(Header h, /*@out@*/struct fileMemory ** memPtr,
 
     fileCount = *fileCountPtr;
 
-    files = *filesPtr = mem->files = malloc(sizeof(*mem->files) * fileCount);
+    files = *filesPtr = mem->files = xcalloc(fileCount, sizeof(*mem->files));
     
     headerGetEntry(h, RPMTAG_FILEFLAGS, NULL, (void **) &fileFlags, NULL);
     headerGetEntry(h, RPMTAG_FILEMODES, NULL, (void **) &fileModes, NULL);
@@ -286,7 +286,7 @@ static void callback(struct cpioCallbackInfo * cpioInfo, void * data)
     if (ourInfo->specFilePtr) {
        chptr = cpioInfo->file + strlen(cpioInfo->file) - 5;
        if (!strcmp(chptr, ".spec")) 
-           *ourInfo->specFilePtr = strdup(cpioInfo->file);
+           *ourInfo->specFilePtr = xstrdup(cpioInfo->file);
     }
 }
 
@@ -535,10 +535,10 @@ static int installSources(Header h, const char * rootdir, FD_t fd,
        }
 
        if (specFilePtr)
-           *specFilePtr = strdup(correctSpecFile);
+           *specFilePtr = xstrdup(correctSpecFile);
     } else {
        if (specFilePtr)
-           *specFilePtr = strdup(files[specFileIndex].relativePath);
+           *specFilePtr = xstrdup(files[specFileIndex].relativePath);
     }
     rc = 0;
 
@@ -633,14 +633,16 @@ int rpmInstallSourcePackage(const char * rootdir, FD_t fd,
        *cookie = NULL;
        if (h != NULL &&
           headerGetEntry(h, RPMTAG_COOKIE, NULL, (void **) cookie, NULL)) {
-           *cookie = strdup(*cookie);
+           *cookie = xstrdup(*cookie);
        }
     }
 
     rpmInstallLoadMacros(h);
     
     rc = installSources(h, rootdir, fd, specFile, notify, notifyData);
-    if (h != NULL) headerFree(h);
+    if (h != NULL) {
+       headerFree(h);
+    }
  
     return rc;
 }
@@ -831,7 +833,7 @@ int installBinaryPackage(const char * rootdir, rpmdb db, FD_t fd, Header h,
            }
        }
 
-       fileStates = malloc(sizeof(*fileStates) * fileCount);
+       fileStates = xmalloc(sizeof(*fileStates) * fileCount);
        for (i = 0; i < fileCount; i++)
            fileStates[i] = files[i].state;
 
@@ -843,7 +845,7 @@ int installBinaryPackage(const char * rootdir, rpmdb db, FD_t fd, Header h,
        fileMem = NULL;
     } else if (flags & RPMTRANS_FLAG_JUSTDB) {
        if (headerGetEntry(h, RPMTAG_FILENAMES, NULL, NULL, &fileCount)) {
-           fileStates = malloc(sizeof(*fileStates) * fileCount);
+           fileStates = xmalloc(sizeof(*fileStates) * fileCount);
            memset(fileStates, RPMFILE_STATE_NORMAL, fileCount);
            headerAddEntry(h, RPMTAG_FILESTATES, RPM_CHAR_TYPE, fileStates, 
                            fileCount);
@@ -908,7 +910,8 @@ exit:
        chdir(currDir);
     }
     if (fileMem) freeFileMemory(fileMem);
-    if (rc)
+    if (rc) {
        headerFree(h);
+    }
     return rc;
 }
index 46cccb4..3131489 100644 (file)
@@ -88,12 +88,13 @@ expandMacroTable(MacroContext *mc)
 {
        if (mc->macroTable == NULL) {
                mc->macrosAllocated = MACRO_CHUNK_SIZE;
-               mc->macroTable = (MacroEntry **)malloc(sizeof(*(mc->macroTable)) *
-                               mc->macrosAllocated);
+               mc->macroTable = (MacroEntry **)
+                   xmalloc(sizeof(*(mc->macroTable)) * mc->macrosAllocated);
                mc->firstFree = 0;
        } else {
                mc->macrosAllocated += MACRO_CHUNK_SIZE;
-               mc->macroTable = (MacroEntry **)realloc(mc->macroTable, sizeof(*(mc->macroTable)) *
+               mc->macroTable = (MacroEntry **)
+                   xrealloc(mc->macroTable, sizeof(*(mc->macroTable)) *
                                mc->macrosAllocated);
        }
        memset(&mc->macroTable[mc->firstFree], 0, MACRO_CHUNK_SIZE * sizeof(*(mc->macroTable)));
@@ -547,12 +548,12 @@ static void
 pushMacro(MacroEntry **mep, const char *n, const char *o, const char *b, int level)
 {
        MacroEntry *prev = (*mep ? *mep : NULL);
-       MacroEntry *me = (MacroEntry *) malloc(sizeof(*me));
+       MacroEntry *me = (MacroEntry *) xmalloc(sizeof(*me));
 
        me->prev = prev;
-       me->name = (prev ? prev->name : strdup(n));
-       me->opts = (o ? strdup(o) : NULL);
-       me->body = strdup(b ? b : "");
+       me->name = (prev ? prev->name : xstrdup(n));
+       me->opts = (o ? xstrdup(o) : NULL);
+       me->body = xstrdup(b ? b : "");
        me->used = 0;
        me->level = level;
        *mep = me;
@@ -1260,7 +1261,7 @@ initMacros(MacroContext *mc, const char *macrofiles)
        if (mc == NULL)
                mc = &globalMacroContext;
 
-       for (mfile = m = strdup(macrofiles); *mfile; mfile = me) {
+       for (mfile = m = xstrdup(macrofiles); *mfile; mfile = me) {
                FILE *fp;
                char buf[BUFSIZ];
 
@@ -1381,7 +1382,7 @@ rpmExpand(const char *arg, ...)
     va_list ap;
 
     if (arg == NULL)
-       return strdup("");
+       return xstrdup("");
 
     p = buf;
     strcpy(p, arg);
@@ -1396,7 +1397,7 @@ rpmExpand(const char *arg, ...)
     }
     va_end(ap);
     expandMacros(NULL, NULL, buf, sizeof(buf));
-    return strdup(buf);
+    return xstrdup(buf);       /* XXX build memory leaks */
 }
 
 int
@@ -1435,7 +1436,7 @@ rpmGetPath(const char *path, ...)
     va_list ap;
 
     if (path == NULL)
-       return strdup("");
+       return xstrdup("");
 
     p = buf;
     strcpy(p, path);
@@ -1455,7 +1456,7 @@ rpmGetPath(const char *path, ...)
     }
     va_end(ap);
     expandMacros(NULL, NULL, buf, sizeof(buf));
-    return strdup(buf);
+    return xstrdup(buf);
 }
 
 /* =============================================================== */
index 20a23e4..2aa2801 100644 (file)
@@ -14,7 +14,7 @@ char ** splitString(const char * str, int length, char sep) {
     int i;
     int fields;
    
-    s = malloc(length + 1);
+    s = xmalloc(length + 1);
     
     fields = 1;
     for (source = str, dest = s, i = 0; i < length; i++, source++, dest++) {
@@ -24,7 +24,7 @@ char ** splitString(const char * str, int length, char sep) {
 
     *dest = '\0';
 
-    list = malloc(sizeof(char *) * (fields + 1));
+    list = xmalloc(sizeof(char *) * (fields + 1));
 
     dest = s;
     list[0] = dest;
@@ -169,7 +169,7 @@ int doputenv(const char *str) {
     
     /* FIXME: this leaks memory! */
 
-    a = malloc(strlen(str) + 1);
+    a = xmalloc(strlen(str) + 1);
     strcpy(a, str);
 
     return putenv(a);
@@ -222,7 +222,7 @@ int unameToUid(char * thisUname, uid_t * uid) {
        strcmp(thisUname, lastUname)) {
        if (lastUnameAlloced < thisUnameLen + 1) {
            lastUnameAlloced = thisUnameLen + 10;
-           lastUname = realloc(lastUname, lastUnameAlloced);
+           lastUname = xrealloc(lastUname, lastUnameAlloced);
        }
        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 = realloc(lastGname, lastGnameAlloced);
+           lastGname = xrealloc(lastGname, lastGnameAlloced);
        }
        strcpy(lastGname, thisGname);
 
@@ -302,7 +302,7 @@ char * uidToUname(uid_t uid) {
        len = strlen(pwent->pw_name);
        if (lastUnameLen < len + 1) {
            lastUnameLen = len + 20;
-           lastUname = realloc(lastUname, lastUnameLen);
+           lastUname = xrealloc(lastUname, lastUnameLen);
        }
        strcpy(lastUname, pwent->pw_name);
 
@@ -332,7 +332,7 @@ char * gidToGname(gid_t gid) {
        len = strlen(grent->gr_name);
        if (lastGnameLen < len + 1) {
            lastGnameLen = len + 20;
-           lastGname = realloc(lastGname, lastGnameLen);
+           lastGname = xrealloc(lastGname, lastGnameLen);
        }
        strcpy(lastGname, grent->gr_name);
 
@@ -396,10 +396,10 @@ char * currentDirectory(void) {
     char * currDir;
 
     currDirLen = 50;
-    currDir = malloc(currDirLen);
+    currDir = xmalloc(currDirLen);
     while (!getcwd(currDir, currDirLen) && errno == ERANGE) {
        currDirLen += 50;
-       currDir = realloc(currDir, currDirLen);
+       currDir = xrealloc(currDir, currDirLen);
     }
 
     return currDir;
index 02b206e..05801d5 100644 (file)
@@ -63,8 +63,8 @@ char * oldhdrReadFromStream(FD_t fd, struct oldrpmHeader * header) {
     groupLength = htonl(lit.groupLength);
     header->iconLength = htonl(lit.iconLength);
 
-    header->spec = malloc(header->specLength);
-    header->name = malloc(strlen(lit.labelstr) + 1);
+    header->spec = xmalloc(header->specLength);
+    header->name = xmalloc(strlen(lit.labelstr) + 1);
     if (!header->spec || !header->name) {
        if (header->spec) free(header->spec);
        if (header->name) free(header->name);
@@ -81,7 +81,7 @@ char * oldhdrReadFromStream(FD_t fd, struct oldrpmHeader * header) {
     header->version = chptr + 1;
 
     if (groupLength) {
-        header->group = malloc(groupLength + 1);
+        header->group = xmalloc(groupLength + 1);
        if (!header->group) {
            free(header->spec);
            free(header->name);
@@ -99,7 +99,7 @@ char * oldhdrReadFromStream(FD_t fd, struct oldrpmHeader * header) {
     }
        
     if (header->iconLength) {
-       header->icon = malloc(header->iconLength);
+       header->icon = xmalloc(header->iconLength);
        if (!header->icon) {
            free(header->spec);
            free(header->name);
@@ -232,27 +232,27 @@ char * oldhdrParseSpec(struct oldrpmHeader * header, struct oldrpmHeaderSpec * s
 
              case PREAMBLE:
                if (!strncmp("Description: ", *strptr, 13))
-                   spec->description = strdup((*strptr) + 13);
+                   spec->description = xstrdup((*strptr) + 13);
                else if (!strncmp("Distribution: ", *strptr, 14))
-                   spec->distribution = strdup((*strptr) + 14);
+                   spec->distribution = xstrdup((*strptr) + 14);
                else if (!strncmp("Vendor: ", *strptr, 8))
-                   spec->vendor = strdup((*strptr) + 8);
+                   spec->vendor = xstrdup((*strptr) + 8);
                else if (!strncmp("BuildHost: ", *strptr, 11))
-                   spec->buildHost = strdup((*strptr) + 11);
+                   spec->buildHost = xstrdup((*strptr) + 11);
                else if (!strncmp("BuildDate: ", *strptr, 11))
                    spec->buildTime = atoi((*strptr) + 11);
                else if (!strncmp("Copyright: ", *strptr, 11))
-                   spec->copyright = strdup((*strptr) + 11);
+                   spec->copyright = xstrdup((*strptr) + 11);
                break;
 
              case PREUN: case PREIN: case POSTIN: case POSTUN:
                if (!*str)  {
-                   *str = malloc(strlen(*strptr) + 2);
+                   *str = xmalloc(strlen(*strptr) + 2);
                    strlength = 0;
                    (*str)[0] = '\0';
                }
                else
-                   *str = realloc(*str, strlength + strlen(*strptr) + 2);
+                   *str = xrealloc(*str, strlength + strlen(*strptr) + 2);
                strcat(*str, *strptr);
                strcat(*str, "\n");
                strlength += strlen(*strptr) + 1;
@@ -261,7 +261,7 @@ char * oldhdrParseSpec(struct oldrpmHeader * header, struct oldrpmHeaderSpec * s
        }
     }
 
-    spec->files = malloc(sizeof(struct oldrpmFileInfo) * spec->fileCount);
+    spec->files = xmalloc(sizeof(struct oldrpmFileInfo) * spec->fileCount);
     if (!spec->files) {
        freeSplitString(lines);
        return "out of memory";
@@ -274,10 +274,10 @@ char * oldhdrParseSpec(struct oldrpmHeader * header, struct oldrpmHeaderSpec * s
 
     freeSplitString(lines);
 
-    if (!spec->vendor) spec->vendor = strdup("");
-    if (!spec->description) spec->description = strdup("");
-    if (!spec->distribution) spec->distribution = strdup("");
-    if (!spec->copyright) spec->copyright = strdup("");
+    if (!spec->vendor) spec->vendor = xstrdup("");
+    if (!spec->description) spec->description = xstrdup("");
+    if (!spec->distribution) spec->distribution = xstrdup("");
+    if (!spec->copyright) spec->copyright = xstrdup("");
 
     return NULL;
 }
@@ -290,7 +290,7 @@ void oldrpmfileFromInfoLine(char * path, char * state, char * str,
 
     fields = splitString(str, strlen(str), ' ');
 
-    fi->path = strdup(path);
+    fi->path = xstrdup(path);
     if (!strcmp(state, "normal"))
        fi->state = RPMFILE_STATE_NORMAL;
     else if (!strcmp(state, "replaced"))
@@ -308,7 +308,7 @@ void oldrpmfileFromSpecLine(char * str, struct oldrpmFileInfo * fi) {
 
     fields = splitString(str, strlen(str), ' ');
 
-    fi->path = strdup(fields[0]);
+    fi->path = xstrdup(fields[0]);
     fi->state = RPMFILE_STATE_NORMAL;
 
     infoFromFields(fields + 1, fi);
@@ -328,7 +328,7 @@ void infoFromFields(char ** fields, struct oldrpmFileInfo * fi) {
     fi->rdev = strtol(fields[8], NULL, 16);
    
     if (S_ISLNK(fi->mode)) {
-       fi->linkto = strdup(fields[9]);
+       fi->linkto = xstrdup(fields[9]);
     } else {
        fi->linkto = NULL;
     }
@@ -343,9 +343,9 @@ char * oldrpmfileToInfoStr(struct oldrpmFileInfo * fi) {
     char * buf;
 
     if (fi->linkto) 
-       buf = malloc(strlen(fi->linkto) + 100);
+       buf = xmalloc(strlen(fi->linkto) + 100);
     else
-       buf = malloc(100);
+       buf = xmalloc(100);
 
     sprintf(buf, "%ld %ld %s %o %d %d %s %s %x ", (long)fi->size, (long)fi->mtime,
                fi->md5, fi->mode, (int)fi->uid, (int)fi->gid,
index 94099f4..05d0810 100644 (file)
@@ -82,20 +82,19 @@ static int readOldHeader(FD_t fd, /*@out@*/Header * hdr, /*@unused@*/ /*@out@*/i
     if (spec.fileCount) {
        /* some packages have no file lists */
 
-       fileList = malloc(sizeof(char *) * spec.fileCount);
-       fileLinktoList = malloc(sizeof(char *) * spec.fileCount);
-       fileMD5List = malloc(sizeof(char *) * spec.fileCount);
-       fileSizeList = malloc(sizeof(int_32) * spec.fileCount);
-       fileUIDList = malloc(sizeof(int_32) * spec.fileCount);
-       fileGIDList = malloc(sizeof(int_32) * spec.fileCount);
-       fileMtimesList = malloc(sizeof(int_32) * spec.fileCount);
-       fileFlagsList = malloc(sizeof(int_32) * spec.fileCount);
-       fileModesList = malloc(sizeof(int_16) * spec.fileCount);
-       fileRDevsList = malloc(sizeof(int_16) * spec.fileCount);
-       fileStatesList = malloc(sizeof(char) * spec.fileCount);
-       unames = malloc(sizeof(char *) * spec.fileCount);
-       gnames = malloc(sizeof(char *) * spec.fileCount);
-
+       fileList = xmalloc(sizeof(char *) * spec.fileCount);
+       fileLinktoList = xmalloc(sizeof(char *) * spec.fileCount);
+       fileMD5List = xmalloc(sizeof(char *) * spec.fileCount);
+       fileSizeList = xmalloc(sizeof(int_32) * spec.fileCount);
+       fileUIDList = xmalloc(sizeof(int_32) * spec.fileCount);
+       fileGIDList = xmalloc(sizeof(int_32) * spec.fileCount);
+       fileMtimesList = xmalloc(sizeof(int_32) * spec.fileCount);
+       fileFlagsList = xmalloc(sizeof(int_32) * spec.fileCount);
+       fileModesList = xmalloc(sizeof(int_16) * spec.fileCount);
+       fileRDevsList = xmalloc(sizeof(int_16) * spec.fileCount);
+       fileStatesList = xmalloc(sizeof(char) * spec.fileCount);
+       unames = xmalloc(sizeof(char *) * spec.fileCount);
+       gnames = xmalloc(sizeof(char *) * spec.fileCount);
 
        /* We also need to contstruct a file owner/group list. We'll just
           hope the numbers all map to something, those that don't will
@@ -128,17 +127,17 @@ static int readOldHeader(FD_t fd, /*@out@*/Header * hdr, /*@unused@*/ /*@out@*/i
 
            unames[j] = uidToUname(fileUIDList[j]);
            if (unames[j])
-               unames[j] = strdup(unames[j]);
+               unames[j] = xstrdup(unames[j]);
            else {
-               unames[j] = malloc(20);
+               unames[j] = xmalloc(20);
                sprintf(unames[j], "uid%d", fileUIDList[j]);
            }
 
            gnames[j] = gidToGname(fileGIDList[j]);
            if (gnames[j])
-               gnames[j] = strdup(gnames[j]);
+               gnames[j] = xstrdup(gnames[j]);
            else {
-               gnames[j] = malloc(20);
+               gnames[j] = xmalloc(20);
                sprintf(gnames[j], "gid%d", fileGIDList[j]);
            }
        }
@@ -268,7 +267,9 @@ static int readPackageHeaders(FD_t fd, /*@out@*/struct rpmlead * leadPtr,
        *hdr = headerRead(fd, (lead->major >= 3) ?
                          HEADER_MAGIC_YES : HEADER_MAGIC_NO);
        if (*hdr == NULL) {
-           if (sigs != NULL) headerFree(*sigs);
+           if (sigs != NULL) {
+               headerFree(*sigs);
+           }
            return 2;
        }
 
@@ -300,7 +301,9 @@ static int readPackageHeaders(FD_t fd, /*@out@*/struct rpmlead * leadPtr,
        /*@notreached@*/ break;
     } 
 
-    if (hdrPtr == NULL) headerFree(*hdr);
+    if (hdrPtr == NULL) {
+       headerFree(*hdr);
+    }
     
     return 0;
 }
index 47ab7b0..04b80ea 100644 (file)
@@ -59,7 +59,7 @@ const char * rpmProblemString(rpmProblem prob)
     if (prob.altH)
        headerNVR(prob.altH, &altName, &altVersion, &altRelease);
 
-    buf = malloc(strlen(name) + strlen(version) + strlen(release) + 400);
+    buf = xmalloc(strlen(name) + strlen(version) + strlen(release) + 400);
 
     switch (prob.type) {
       case RPMPROB_BADARCH:
index 4d61e21..3230c93 100644 (file)
@@ -4,14 +4,13 @@
 # define PATH_MAX 255
 #endif
 
-#include "build/rpmbuild.h"
-#include "popt/popt.h"
+#include "rpmbuild.h"
 #include <rpmurl.h>
 
 /* ======================================================================== */
 static char * permsString(int mode)
 {
-    char *perms = strdup("----------");
+    char *perms = xstrdup("----------");
    
     if (S_ISDIR(mode)) 
        perms[0] = 'd';
@@ -328,9 +327,9 @@ printNewSpecfile(Spec spec)
            headerGetEntry(spec->packages->header, RPMTAG_NAME, NULL,
                (void **) &n, NULL);
            sprintf(buf, "%s(%s)", n, tagName(t->t_tag));
-           t->t_msgid = strdup(buf);
+           t->t_msgid = xstrdup(buf);
        }
-       msgstr = strdup(dgettext(specedit, t->t_msgid));
+       msgstr = xstrdup(dgettext(specedit, t->t_msgid));
 
        switch(t->t_tag) {
        case RPMTAG_SUMMARY:
@@ -342,7 +341,7 @@ printNewSpecfile(Spec spec)
            sprintf(buf, "%s: %s\n",
                ((t->t_tag == RPMTAG_GROUP) ? "Group" : "Summary"),
                msgstr);
-           sl->sl_lines[t->t_startx] = strdup(buf);
+           sl->sl_lines[t->t_startx] = xstrdup(buf);
            break;
        case RPMTAG_DESCRIPTION:
            for (j = 1; j < t->t_nlines; j++) {
@@ -354,9 +353,9 @@ printNewSpecfile(Spec spec)
                sl->sl_lines[t->t_startx] = NULL;
                continue;
            }
-           sl->sl_lines[t->t_startx + 1] = strdup(msgstr);
+           sl->sl_lines[t->t_startx + 1] = xstrdup(msgstr);
            if (t->t_nlines > 2)
-               sl->sl_lines[t->t_startx + 2] = strdup("\n\n");
+               sl->sl_lines[t->t_startx + 2] = xstrdup("\n\n");
            break;
        }
     }
@@ -725,10 +724,10 @@ static void queryArgCallback(/*@unused@*/poptContext con, /*@unused@*/enum poptC
       {        char *qf = (char *)qva->qva_queryFormat;
        if (qf) {
            int len = strlen(qf) + strlen(arg) + 1;
-           qf = realloc(qf, len);
+           qf = xrealloc(qf, len);
            strcat(qf, arg);
        } else {
-           qf = malloc(strlen(arg) + 1);
+           qf = xmalloc(strlen(arg) + 1);
            strcpy(qf, arg);
        }
        qva->qva_queryFormat = qf;
index 84a0cdb..fdeabdc 100644 (file)
@@ -5,7 +5,8 @@
 
 #include "rpmdb.h"
 
-int rpmdbRebuild(const char * rootdir) {
+int rpmdbRebuild(const char * rootdir)
+{
     rpmdb olddb, newdb;
     const char * dbpath = NULL;
     const char * newdbpath = NULL;
index d525575..d0ada68 100644 (file)
@@ -135,7 +135,7 @@ static int openDbFile(const char * prefix, const char * dbpath, const char * sho
 
 static /*@only@*/ rpmdb newRpmdb(void)
 {
-    rpmdb db = malloc(sizeof(*db));
+    rpmdb db = xmalloc(sizeof(*db));
     db->pkgs = NULL;
     db->nameIndex = NULL;
     db->fileIndex = NULL;
@@ -220,9 +220,9 @@ int openDatabase(const char * prefix, const char * dbpath, rpmdb *rpmdbp, int mo
                    &db->nameIndex, DB_HASH);
 
     if (minimal) {
-       *rpmdbp = malloc(sizeof(struct rpmdb_s));
+       *rpmdbp = xmalloc(sizeof(struct rpmdb_s));
        if (rpmdbp)
-           *rpmdbp = db;
+           *rpmdbp = db;       /* structure assignment */
        else
            rpmdbClose(db);
        return 0;
@@ -784,8 +784,7 @@ int rpmdbFindFpList(rpmdb db, fingerPrint * fpList, dbiIndexSet * matchList,
     /* this may be worth batching by basename, but probably not as
        basenames are quite unique as it is */
 
-    intMatches = malloc(sizeof(*intMatches) * intMatchesAlloced);
-    memset(intMatches, 0, sizeof(*intMatches) * intMatchesAlloced);
+    intMatches = xcalloc(intMatchesAlloced, sizeof(*intMatches));
 
     /* Gather all matches from the database */
     for (i = 0; i < numItems; i++) {
@@ -801,7 +800,7 @@ int rpmdbFindFpList(rpmdb db, fingerPrint * fpList, dbiIndexSet * matchList,
            if ((numIntMatches + dbiIndexSetCount(matches)) >= intMatchesAlloced) {
                intMatchesAlloced += dbiIndexSetCount(matches);
                intMatchesAlloced += intMatchesAlloced / 5;
-               intMatches = realloc(intMatches, 
+               intMatches = xrealloc(intMatches, 
                                     sizeof(*intMatches) * intMatchesAlloced);
            }
 
@@ -850,13 +849,11 @@ int rpmdbFindFpList(rpmdb db, fingerPrint * fpList, dbiIndexSet * matchList,
            headerGetEntryMinMemory(h, RPMTAG_FILENAMES, NULL, 
                                (void **) &fullfl, &fc);
 
-           fl = malloc(sizeof(*fl) * num);
-           memset(fl, 0, sizeof(*fl) * num);
+           fl = xcalloc(num, sizeof(*fl));
            for (i = 0; i < num; i++)
                fl[i] = fullfl[im[i].rec.fileNumber];
            free(fullfl);
-           fps = malloc(sizeof(*fps) * num);
-           memset(fps, 0, sizeof(*fps) * num);
+           fps = xcalloc(num, sizeof(*fps));
            fpLookupList(fl, fps, num, 1);
            free(fl);
        }
index abb24dd..fe8081d 100644 (file)
@@ -234,7 +234,7 @@ int rpmInstall(const char * rootdir, const char ** argv, int transFlags,
 
                    if (headerGetEntry(h, RPMTAG_PREFIXES, NULL,
                                       (void **) &paths, &c) && (c == 1)) {
-                       defaultReloc->oldPath = strdup(paths[0]);
+                       defaultReloc->oldPath = xstrdup(paths[0]);
                        free(paths);
                    } else {
                        headerGetEntry(h, RPMTAG_NAME, NULL, (void **) &name,
@@ -249,15 +249,24 @@ int rpmInstall(const char * rootdir, const char ** argv, int transFlags,
                rc = rpmtransAddPackage(rpmdep, h, NULL, *filename,
                               (interfaceFlags & INSTALL_UPGRADE) != 0,
                               relocations);
-               if (rc) {
-                   if (rc == 1)
+
+               headerFree(h);  /* XXX reference held by transaction set */
+               fdClose(fd);
+
+               switch(rc) {
+               case 0:
+                       break;
+               case 1:
                        rpmMessage(RPMMESS_ERROR, 
                            _("error reading from file %s\n"), *filename);
-                   else if (rc == 2)
+                       return numPackages;
+                       /*@notreached@*/ break;
+               case 2:
                        rpmMessage(RPMMESS_ERROR, 
                            _("file %s requires a newer version of RPM\n"),
                            *filename);
-                   return numPackages;
+                       return numPackages;
+                       /*@notreached@*/ break;
                }
 
                if (defaultReloc) {
@@ -265,7 +274,6 @@ int rpmInstall(const char * rootdir, const char ** argv, int transFlags,
                    defaultReloc->oldPath = NULL;
                }
 
-               fdClose(fd);
                numBinaryPackages++;
            }
            break;
index 3c95019..dd88d6e 100644 (file)
@@ -279,6 +279,7 @@ void rpmSetTables(int archTable, int osTable);  /* only used by build code */
    pushed through a translation table (if appropriate) */
 void rpmSetMachine(const char * arch, const char * os);
 void rpmGetMachine(/*@out@*/char **arch, /*@out@*/char **os);
+void rpmFreeRpmrc(void);
 
 /** **/
 
index 47b3007..961c394 100644 (file)
@@ -150,7 +150,6 @@ static int optionCompare(const void * a, const void * b) {
 
 static void rpmRebuildTargetVars(const char **target, const char ** canontarget);
 
-
 static struct machCacheEntry * machCacheFindEntry(struct machCache * cache,
                                                  char * key)
 {
@@ -202,10 +201,10 @@ static int machCompatCacheAdd(char * name, const char * fn, int linenum,
     }
 
     if (!entry) {
-       cache->cache = realloc(cache->cache,
+       cache->cache = xrealloc(cache->cache,
                               (cache->size + 1) * sizeof(*cache->cache));
        entry = cache->cache + cache->size++;
-       entry->name = strdup(name);
+       entry->name = xstrdup(name);
        entry->count = 0;
        entry->visited = 0;
     }
@@ -217,12 +216,12 @@ static int machCompatCacheAdd(char * name, const char * fn, int linenum,
        if (chptr[0] == '\0')   /* does strtok() return "" ever?? */
            continue;
        if (entry->count)
-           entry->equivs = realloc(entry->equivs, sizeof(*entry->equivs)
+           entry->equivs = xrealloc(entry->equivs, sizeof(*entry->equivs)
                                        * (entry->count + 1));
        else
-           entry->equivs = malloc(sizeof(*entry->equivs));
+           entry->equivs = xmalloc(sizeof(*entry->equivs));
 
-       entry->equivs[entry->count] = strdup(chptr);
+       entry->equivs[entry->count] = xstrdup(chptr);
        entry->count++;
     }
 
@@ -257,12 +256,12 @@ static void machAddEquiv(struct machEquivTable * table, char * name,
     equiv = machEquivSearch(table, name);
     if (!equiv) {
        if (table->count)
-           table->list = realloc(table->list, (table->count + 1)
+           table->list = xrealloc(table->list, (table->count + 1)
                                    * sizeof(*table->list));
        else
-           table->list = malloc(sizeof(*table->list));
+           table->list = xmalloc(sizeof(*table->list));
 
-       table->list[table->count].name = strdup(name);
+       table->list[table->count].name = xstrdup(name);
        table->list[table->count++].score = distance;
     }
 }
@@ -315,10 +314,10 @@ static int addCanon(struct canonEntry **table, int *tableLen, char *line,
 
     if (! *tableLen) {
        *tableLen = 2;
-       *table = malloc(2 * sizeof(struct canonEntry));
+       *table = xmalloc(2 * sizeof(struct canonEntry));
     } else {
        (*tableLen) += 2;
-       *table = realloc(*table, sizeof(struct canonEntry) * (*tableLen));
+       *table = xrealloc(*table, sizeof(struct canonEntry) * (*tableLen));
     }
     t = & ((*table)[*tableLen - 2]);
 
@@ -342,13 +341,13 @@ static int addCanon(struct canonEntry **table, int *tableLen, char *line,
        return(RPMERR_RPMRC);
     }
 
-    t->name = strdup(t->name);
-    t->short_name = strdup(t->short_name);
+    t->name = xstrdup(t->name);
+    t->short_name = xstrdup(t->short_name);
 
     /* From A B C entry */
     /* Add  B B C entry */
-    t[1].name = strdup(t->short_name);
-    t[1].short_name = strdup(t->short_name);
+    t[1].name = xstrdup(t->short_name);
+    t[1].short_name = xstrdup(t->short_name);
     t[1].num = t->num;
 
     return 0;
@@ -361,10 +360,10 @@ static int addDefault(struct defaultEntry **table, int *tableLen, char *line,
 
     if (! *tableLen) {
        *tableLen = 1;
-       *table = malloc(sizeof(struct defaultEntry));
+       *table = xmalloc(sizeof(struct defaultEntry));
     } else {
        (*tableLen)++;
-       *table = realloc(*table, sizeof(struct defaultEntry) * (*tableLen));
+       *table = xrealloc(*table, sizeof(struct defaultEntry) * (*tableLen));
     }
     t = & ((*table)[*tableLen - 1]);
 
@@ -381,8 +380,8 @@ static int addDefault(struct defaultEntry **table, int *tableLen, char *line,
        return RPMERR_RPMRC;
     }
 
-    t->name = strdup(t->name);
-    t->defName = strdup(t->defName);
+    t->name = xstrdup(t->name);
+    t->defName = xstrdup(t->defName);
 
     return 0;
 }
@@ -544,7 +543,7 @@ int rpmReadRC(const char * rcfiles)
 
     /* Read each file in rcfiles. */
     rc = 0;
-    for (r = myrcfiles = strdup(rcfiles); *r != '\0'; r = re) {
+    for (r = myrcfiles = xstrdup(rcfiles); *r != '\0'; r = re) {
        char fn[4096];
        FD_t fd;
 
@@ -703,7 +702,7 @@ static int doReadRC(FD_t fd, const char * filename)
              { char *t;
                s = rpmGetVar(RPMVAR_PROVIDES);
                if (s == NULL) s = "";
-               fn = t = malloc(strlen(s) + strlen(se) + 2);
+               fn = t = xmalloc(strlen(s) + strlen(se) + 2);
                while (*s) *t++ = *s++;
                *t++ = ' ';
                while (*se) *t++ = *se++;
@@ -739,7 +738,7 @@ static int doReadRC(FD_t fd, const char * filename)
            if (option->macroize &&
              (arch == NULL || !strcmp(arch, current[ARCH]))) {
                char *n, *name;
-               n = name = malloc(strlen(option->name)+2);
+               n = name = xmalloc(strlen(option->name)+2);
                if (option->localize)
                    *n++ = '_';
                strcpy(n, option->name);
@@ -849,7 +848,7 @@ static void defaultMachine(char ** arch, char ** os) {
           char *prelid = NULL;
            FD_t fd = fdOpen("/etc/.relid", O_RDONLY, 0700);
            if (fdFileno(fd) > 0) {
-              chptr = (char *) calloc(256,1);
+              chptr = (char *) xcalloc(1, 256);
               if (chptr != NULL) {
                  int irelid = fdRead(fd, (void *)chptr, 256);
                  fdClose(fd);
@@ -1013,7 +1012,7 @@ static void freeRpmVar(struct rpmvarValue * orig) {
 
 void rpmSetVar(int var, const char *val) {
     freeRpmVar(&values[var]);
-    values[var].value = (val ? strdup(val) : NULL);
+    values[var].value = (val ? xstrdup(val) : NULL);
 }
 
 static void rpmSetVarArch(int var, const char * val, const char * arch) {
@@ -1036,14 +1035,14 @@ static void rpmSetVarArch(int var, const char * val, const char * arch) {
            if (next->value) free(next->value);
            if (next->arch) free(next->arch);
        } else if (next->arch || arch) {
-           next->next = malloc(sizeof(*next->next));
+           next->next = xmalloc(sizeof(*next->next));
            next = next->next;
            next->next = NULL;
        }
     }
 
-    next->value = strdup(val);
-    next->arch = (arch ? strdup(arch) : NULL);
+    next->value = xstrdup(val);
+    next->arch = (arch ? xstrdup(arch) : NULL);
 }
 
 void rpmSetTables(int archTable, int osTable) {
@@ -1099,13 +1098,13 @@ void rpmSetMachine(const char * arch, const char * os) {
 
     if (!current[ARCH] || strcmp(arch, current[ARCH])) {
        if (current[ARCH]) free(current[ARCH]);
-       current[ARCH] = strdup(arch);
+       current[ARCH] = xstrdup(arch);
        rebuildCompatTables(ARCH, host_cpu);
     }
 
     if (!current[OS] || strcmp(os, current[OS])) {
        if (current[OS]) free(current[OS]);
-       current[OS] = strdup(os);
+       current[OS] = xstrdup(os);
        /*
         * XXX Capitalizing the 'L' is needed to insure that old
         * XXX os-from-uname (e.g. "Linux") is compatible with the new
@@ -1174,7 +1173,7 @@ void rpmRebuildTargetVars(const char **buildtarget, const char ** canontarget)
     if (buildtarget && *buildtarget) {
        char *c;
        /* Set arch and os from specified build target */
-       ca = strdup(*buildtarget);
+       ca = xstrdup(*buildtarget);
        if ((c = strchr(ca, '-')) != NULL) {
            *c++ = '\0';
            
@@ -1188,34 +1187,34 @@ void rpmRebuildTargetVars(const char **buildtarget, const char ** canontarget)
                else
                    co++;
            }
-           if (co != NULL) co = strdup(co);
+           if (co != NULL) co = xstrdup(co);
        }
     } else {
        /* Set build target from rpm arch and os */
        rpmGetArchInfo(&ca,NULL);
-       if (ca) ca = strdup(ca);
+       if (ca) ca = xstrdup(ca);
        rpmGetOsInfo(&co,NULL);
-       if (co) co = strdup(co);
+       if (co) co = xstrdup(co);
     }
 
     /* If still not set, Set target arch/os from default uname(2) values */
     if (ca == NULL) {
        defaultMachine(&ca, NULL);
-       ca = strdup(ca);
+       ca = xstrdup(ca);
      }
     for (x = 0; ca[x]; x++)
        ca[x] = tolower(ca[x]);
 
     if (co == NULL) {
        defaultMachine(NULL, &co);
-       co = strdup(co);
+       co = xstrdup(co);
     }
     for (x = 0; co[x]; x++)
        co[x] = tolower(co[x]);
 
     /* XXX For now, set canonical target to arch-os */
     if (ct == NULL) {
-       ct = malloc(strlen(ca) + sizeof("-") + strlen(co));
+       ct = xmalloc(strlen(ca) + sizeof("-") + strlen(co));
        sprintf(ct, "%s-%s", ca, co);
     }
 
@@ -1247,6 +1246,66 @@ void rpmRebuildTargetVars(const char **buildtarget, const char ** canontarget)
     free(co);
 }
 
+void rpmFreeRpmrc(void)
+{
+    int i, j, k;
+
+    for (i = 0; i < RPM_MACHTABLE_COUNT; i++) {
+       struct tableType *t;
+       t = tables + i;
+       if (t->equiv.list) {
+           for (j = 0; j < t->equiv.count; j++) {
+               if (t->equiv.list[j].name)      xfree(t->equiv.list[j].name);
+           }
+           xfree(t->equiv.list);
+       }
+       if (t->cache.cache) {
+           for (j = 0; j < t->cache.size; j++) {
+               struct machCacheEntry *e;
+               e = t->cache.cache + j;
+               if (e == NULL)  continue;
+               if (e->name)            xfree(e->name);
+               if (e->equivs) {
+                   for (k = 0; k < e->count; k++) {
+                   if (e->equivs[k])   xfree(e->equivs[k]);
+                   }
+                   xfree(e->equivs);
+               }
+           }
+           xfree(t->cache.cache);
+       }
+       if (t->defaults) {
+           for (j = 0; j < t->defaultsLength; j++) {
+               if (t->defaults[j].name)        xfree(t->defaults[j].name);
+               if (t->defaults[j].defName)     xfree(t->defaults[j].defName);
+           }
+           xfree(t->defaults);
+       }
+       if (t->canons) {
+           for (j = 0; j < t->canonsLength; j++) {
+               if (t->canons[j].name)          xfree(t->canons[j].name);
+               if (t->canons[j].short_name)    xfree(t->canons[j].short_name);
+           }
+           xfree(t->canons);
+       }
+    }
+
+    for (i = 0; i < RPMVAR_NUM; i++) {
+       struct rpmvarValue *this;
+       while ((this = values[i].next) != NULL) {
+           values[i].next = this->next;
+           if (this->value)    xfree(this->value);
+           if (this->arch)     xfree(this->arch);
+           xfree(this);
+       }
+       if (values[i].value)    xfree(values[i].value);
+       if (values[i].arch)     xfree(values[i].arch);
+    }
+    if (current[OS])   xfree(current[OS]);
+    if (current[ARCH]) xfree(current[ARCH]);
+    return;
+}
+
 int rpmShowRC(FILE *f)
 {
     struct rpmOption *opt;
index 18cab28..76075d8 100644 (file)
@@ -210,7 +210,8 @@ int rpmWriteSignature(FD_t fd, Header header)
 
 Header rpmNewSignature(void)
 {
-    return headerNew();
+    Header h = headerNew();
+    return h;
 }
 
 void rpmFreeSignature(Header h)
@@ -286,7 +287,7 @@ static int makePGPSignature(const char *file, /*@out@*/void **sig, /*@out@*/int_
 
     *size = statbuf.st_size;
     rpmMessage(RPMMESS_DEBUG, _("PGP sig size: %d\n"), *size);
-    *sig = malloc(*size);
+    *sig = xmalloc(*size);
     
     {  FD_t fd;
        int rc;
@@ -363,7 +364,7 @@ static int makeGPGSignature(const char *file, /*@out@*/void **sig, /*@out@*/int_
 
     *size = statbuf.st_size;
     rpmMessage(RPMMESS_DEBUG, _("GPG sig size: %d\n"), *size);
-    *sig = malloc(*size);
+    *sig = xmalloc(*size);
     
     {  FD_t fd;
        int rc;
index 23f81d2..2317086 100644 (file)
@@ -13,13 +13,12 @@ struct StringBufRec {
 
 StringBuf newStringBuf(void)
 {
-    StringBuf sb = malloc(sizeof(struct StringBufRec));
+    StringBuf sb = xmalloc(sizeof(struct StringBufRec));
 
-    sb->buf = malloc(BUF_CHUNK * sizeof(char));
+    sb->free = sb->allocated = BUF_CHUNK;
+    sb->buf = xcalloc(sb->allocated, sizeof(*sb->buf));
     sb->buf[0] = '\0';
     sb->tail = sb->buf;
-    sb->allocated = BUF_CHUNK;
-    sb->free = BUF_CHUNK;
     
     return sb;
 }
@@ -67,7 +66,7 @@ void appendStringBufAux(StringBuf sb, const char *s, int nl)
     while ((l + nl + 1) > sb->free) {
         sb->allocated += BUF_CHUNK;
        sb->free += BUF_CHUNK;
-        sb->buf = realloc(sb->buf, sb->allocated);
+        sb->buf = xrealloc(sb->buf, sb->allocated);
        sb->tail = sb->buf + (sb->allocated - sb->free);
     }
     
index af0d5bc..b5e3326 100644 (file)
@@ -138,7 +138,7 @@ static rpmProblemSet psCreate(void)
 {
     rpmProblemSet probs;
 
-    probs = malloc(sizeof(*probs));
+    probs = xmalloc(sizeof(*probs));
     probs->numProblems = probs->numProblemsAlloced = 0;
     probs->probs = NULL;
 
@@ -154,7 +154,7 @@ static void psAppend(rpmProblemSet probs, rpmProblemType type,
            probs->numProblemsAlloced *= 2;
        else
            probs->numProblemsAlloced = 2;
-       probs->probs = realloc(probs->probs,
+       probs->probs = xrealloc(probs->probs,
                        probs->numProblemsAlloced * sizeof(*probs->probs));
     }
 
@@ -163,13 +163,13 @@ static void psAppend(rpmProblemSet probs, rpmProblemType type,
     probs->probs[probs->numProblems].h = headerLink(h);
     probs->probs[probs->numProblems].ulong1 = ulong1;
     if (str1)
-       probs->probs[probs->numProblems].str1 = strdup(str1);
+       probs->probs[probs->numProblems].str1 = xstrdup(str1);
     else
        probs->probs[probs->numProblems].str1 = NULL;
 
-    if (altH)
+    if (altH) {
        probs->probs[probs->numProblems].altH = headerLink(altH);
-    else
+    else
        probs->probs[probs->numProblems].altH = NULL;
 
     probs->probs[probs->numProblems++].ignoreProblem = 0;
@@ -228,7 +228,9 @@ void rpmProblemSetFree(rpmProblemSet probs)
     for (i = 0; i < probs->numProblems; i++) {
        headerFree(probs->probs[i].h);
        if (probs->probs[i].str1) free(probs->probs[i].str1);
-       if (probs->probs[i].altH) headerFree(probs->probs[i].altH);
+       if (probs->probs[i].altH) {
+           headerFree(probs->probs[i].altH);
+       }
     }
     free(probs);
 }
@@ -252,7 +254,10 @@ static Header relocateFileList(struct availablePackage * alp,
                        (void **) &validRelocations, &numValid))
        numValid = 0;
 
-    if (!rawRelocations && !numValid) return headerLink(origH);
+    if (!rawRelocations && !numValid) {
+       Header oH =  headerLink(origH);
+       return oH;
+    }
 
     h = headerCopy(origH);
 
@@ -314,7 +319,7 @@ static Header relocateFileList(struct availablePackage * alp,
     /* Add relocation values to the header */
     if (numValid) {
        const char ** actualRelocations;
-       actualRelocations = malloc(sizeof(*actualRelocations) * numValid);
+       actualRelocations = xmalloc(sizeof(*actualRelocations) * numValid);
        for (i = 0; i < numValid; i++) {
            for (j = 0; j < numRelocations; j++) {
                if (strcmp(validRelocations[i], relocations[j].oldPath))
@@ -600,7 +605,7 @@ static int handleInstInstalledFiles(TFI_t * fi, rpmdb db,
     headerGetEntryMinMemory(h, RPMTAG_FILESIZES, NULL,
                            (void **) &otherSizes, NULL);
 
-    fi->replaced = malloc(sizeof(*fi->replaced) * sharedCount);
+    fi->replaced = xmalloc(sizeof(*fi->replaced) * sharedCount);
 
     for (i = 0; i < sharedCount; i++, shared++) {
        int otherFileNum, fileNum;
@@ -645,7 +650,7 @@ static int handleInstInstalledFiles(TFI_t * fi, rpmdb db,
     free(otherLinks);
     headerFree(h);
 
-    fi->replaced = realloc(fi->replaced,
+    fi->replaced = xrealloc(fi->replaced,
                           sizeof(*fi->replaced) * (numReplaced + 1));
     fi->replaced[numReplaced].otherPkg = 0;
 
@@ -1150,7 +1155,7 @@ int rpmRunTransactions(rpmTransactionSet ts, rpmCallbackFunction notify,
            }
 
            /* Allocate file actions (and initialize to RPMFILE_STATE_NORMAL) */
-           fi->actions = calloc(sizeof(*fi->actions), fi->fc);
+           fi->actions = xcalloc(fi->fc, sizeof(*fi->actions));
            hdrs[i] = relocateFileList(alp, probs, alp->h, fi->actions,
                                  ignoreSet & RPMPROB_FILTER_FORCERELOCATE);
            fi->h = headerLink(hdrs[i]);
@@ -1177,7 +1182,7 @@ int rpmRunTransactions(rpmTransactionSet ts, rpmCallbackFunction notify,
 
        /* actions is initialized earlier for added packages */
        if (fi->actions == NULL)
-           fi->actions = calloc(sizeof(*fi->actions), fi->fc);
+           fi->actions = xcalloc(fi->fc, sizeof(*fi->actions));
 
        headerGetEntry(fi->h, RPMTAG_FILEMODES, NULL,
                                (void **) &fi->fmodes, NULL);
@@ -1194,13 +1199,13 @@ int rpmRunTransactions(rpmTransactionSet ts, rpmCallbackFunction notify,
                                    (void **) &fi->fmd5s, NULL);
            headerGetEntry(fi->h, RPMTAG_FILELINKTOS, NULL,
                                    (void **) &fi->flinks, NULL);
-           fi->fsizes = memcpy(malloc(fi->fc * sizeof(*fi->fsizes)),
+           fi->fsizes = memcpy(xmalloc(fi->fc * sizeof(*fi->fsizes)),
                                fi->fsizes, fi->fc * sizeof(*fi->fsizes));
-           fi->fflags = memcpy(malloc(fi->fc * sizeof(*fi->fflags)),
+           fi->fflags = memcpy(xmalloc(fi->fc * sizeof(*fi->fflags)),
                                fi->fflags, fi->fc * sizeof(*fi->fflags));
-           fi->fmodes = memcpy(malloc(fi->fc * sizeof(*fi->fmodes)),
+           fi->fmodes = memcpy(xmalloc(fi->fc * sizeof(*fi->fmodes)),
                                fi->fmodes, fi->fc * sizeof(*fi->fmodes));
-           fi->fstates = memcpy(malloc(fi->fc * sizeof(*fi->fstates)),
+           fi->fstates = memcpy(xmalloc(fi->fc * sizeof(*fi->fstates)),
                                fi->fstates, fi->fc * sizeof(*fi->fstates));
            headerFree(fi->h);
            fi->h = NULL;
@@ -1212,14 +1217,14 @@ int rpmRunTransactions(rpmTransactionSet ts, rpmCallbackFunction notify,
                                    (void **) &fi->flinks, NULL);
 
            /* 0 makes for noops */
-           fi->replacedSizes = calloc(fi->fc, sizeof(*fi->replacedSizes));
+           fi->replacedSizes = xcalloc(fi->fc, sizeof(*fi->replacedSizes));
 
            /* Skip netshared paths, not our i18n files, and excluded docs */
            skipFiles(fi, flags & RPMTRANS_FLAG_NODOCS);
            break;
        }
 
-        fi->fps = malloc(fi->fc * sizeof(*fi->fps));
+        fi->fps = xmalloc(sizeof(*fi->fps) * fi->fc);
     }
 
     /* There are too many returns to plug this leak. Use alloca instead. */
@@ -1257,7 +1262,7 @@ int rpmRunTransactions(rpmTransactionSet ts, rpmCallbackFunction notify,
               NULL, notifyData));
 
        /* Extract file info for all files in this package from the database. */
-       matches = malloc(sizeof(*matches) * fi->fc);
+       matches = xmalloc(sizeof(*matches) * fi->fc);
        if (rpmdbFindFpList(ts->db, fi->fps, matches, fi->fc)) return 1;
 
        numShared = 0;
@@ -1265,7 +1270,7 @@ int rpmRunTransactions(rpmTransactionSet ts, rpmCallbackFunction notify,
            numShared += dbiIndexSetCount(matches[i]);
 
        /* Build sorted file info list for this package. */
-       shared = sharedList = malloc(sizeof(*sharedList) * (numShared + 1));
+       shared = sharedList = xmalloc(sizeof(*sharedList) * (numShared + 1));
        for (i = 0; i < fi->fc; i++) {
            /*
             * Take care not to mark files as replaced in packages that will
index 888d37b..1d4c0e5 100644 (file)
@@ -208,7 +208,9 @@ int removeBinaryPackage(const char * prefix, rpmdb db, unsigned int offset,
     rc = 0;
 
  exit:
-    if (h)     headerFree(h);
+    if (h) {
+       headerFree(h);
+    }
     return rc;
 }
 
@@ -393,7 +395,7 @@ int runInstScript(const char * root, Header h, int scriptTag, int progTag,
     }
 
     rc = runScript(h, root, programArgc, argv, script, arg, -1, err);
-    if (programType == RPM_STRING_ARRAY_TYPE) free(programArgv);
+    if (programArgv && programType == RPM_STRING_ARRAY_TYPE) free(programArgv);
     return rc;
 }
 
index 3df1c95..3fdf1f8 100644 (file)
--- a/lib/url.c
+++ b/lib/url.c
@@ -110,9 +110,9 @@ static void findUrlinfo(urlinfo **uret, int mustAsk)
        if (empty == NULL) {
            uCount++;
            if (uCache)
-               uCache = realloc(uCache, sizeof(*uCache) * uCount);
+               uCache = xrealloc(uCache, sizeof(*uCache) * uCount);
            else
-               uCache = malloc(sizeof(*uCache));
+               uCache = xmalloc(sizeof(*uCache));
            empty = &uCache[i];
        }
        *empty = u;
@@ -142,19 +142,19 @@ static void findUrlinfo(urlinfo **uret, int mustAsk)
            FREE(u->password);
            prompt = alloca(strlen(u->host) + strlen(u->user) + 40);
            sprintf(prompt, _("Password for %s@%s: "), u->user, u->host);
-           u->password = strdup(getpass(prompt));
+           u->password = xstrdup(getpass(prompt));
        }
 
        if (u->proxyh == NULL) {
            const char *proxy = rpmExpand("%{_ftpproxy}", NULL);
            if (proxy && *proxy != '%') {
                const char *uu = (u->user ? u->user : "anonymous");
-               char *nu = malloc(strlen(uu) + sizeof("@") + strlen(u->host));
+               char *nu = xmalloc(strlen(uu) + sizeof("@") + strlen(u->host));
                strcpy(nu, uu);
                strcat(nu, "@");
                strcat(nu, u->host);
                u->proxyu = nu;
-               u->proxyh = strdup(proxy);
+               u->proxyh = xstrdup(proxy);
            }
            xfree(proxy);
        }
@@ -181,7 +181,7 @@ static void findUrlinfo(urlinfo **uret, int mustAsk)
        if (u->proxyh == NULL) {
            const char *proxy = rpmExpand("%{_httpproxy}", NULL);
            if (proxy && *proxy != '%')
-               u->proxyh = strdup(proxy);
+               u->proxyh = xstrdup(proxy);
            xfree(proxy);
        }
 
@@ -220,12 +220,12 @@ int urlSplit(const char * url, urlinfo **uret)
     if ((u = newUrlinfo()) == NULL)
        return -1;
 
-    if ((se = s = myurl = strdup(url)) == NULL) {
+    if ((se = s = myurl = xstrdup(url)) == NULL) {
        freeUrlinfo(u);
        return -1;
     }
 
-    u->url = strdup(url);
+    u->url = xstrdup(url);
 
     do {
        /* Point to end of next item */
@@ -239,14 +239,14 @@ int urlSplit(const char * url, urlinfo **uret)
        /* Item was service. Save service and go for the rest ...*/
        if ((se != s) && se[-1] == ':' && se[0] == '/' && se[1] == '/') {
                se[-1] = '\0';
-           u->service = strdup(s);
+           u->service = xstrdup(s);
            se += 2;    /* skip over "//" */
            s = se++;
            continue;
        }
        
        /* Item was everything-but-path. Save path and continue parse on rest */
-       u->path = strdup(se);
+       u->path = xstrdup(se);
        *se = '\0';
        break;
     } while (1);
@@ -261,9 +261,9 @@ int urlSplit(const char * url, urlinfo **uret)
        while (fe > f && *fe != ':') fe--;
        if (*fe == ':') {
            *fe++ = '\0';
-           u->password = strdup(fe);
+           u->password = xstrdup(fe);
        }
-       u->user = strdup(f);
+       u->user = xstrdup(f);
     }
 
     /* Look for ...host:port */
@@ -271,7 +271,7 @@ int urlSplit(const char * url, urlinfo **uret)
     while (*fe && *fe != ':') fe++;
     if (*fe == ':') {
        *fe++ = '\0';
-       u->portstr = strdup(fe);
+       u->portstr = xstrdup(fe);
        if (u->portstr != NULL && u->portstr[0] != '\0') {
            char *end;
            u->port = strtol(u->portstr, &end, 0);
@@ -283,7 +283,7 @@ int urlSplit(const char * url, urlinfo **uret)
            }
        }
     }
-    u->host = strdup(f);
+    u->host = xstrdup(f);
 
     if (u->port < 0 && u->service != NULL) {
        struct servent *serv;
index a1fcffe..61fad49 100644 (file)
@@ -17,10 +17,10 @@ char * oldrpmdbLabelToLabelstr(struct oldrpmdbLabel label, int withFileNum) {
     char buffer[50];
  
     if (withFileNum && label.fileNumber > -1) 
-       c = malloc(strlen(label.name) + strlen(label.version) + 
+       c = xmalloc(strlen(label.name) + strlen(label.version) + 
                   strlen(label.release) + 10);
     else
-       c = malloc(strlen(label.name) + strlen(label.version) + 
+       c = xmalloc(strlen(label.name) + strlen(label.version) + 
                   strlen(label.release) + 3);
 
     strcpy(c, label.name);
@@ -387,7 +387,7 @@ static char * getScript(char * which, struct oldrpmdb *oldrpmdb,
     char * labelstr, * l;
 
     labelstr = oldrpmdbLabelToLabelstr(label, 0);
-    labelstr = realloc(labelstr, strlen(labelstr) + 10);
+    labelstr = xrealloc(labelstr, strlen(labelstr) + 10);
     strcat(labelstr, ":");
     strcat(labelstr, which);
 
index ba77d05..1d09962 100644 (file)
@@ -6,7 +6,7 @@
 msgid ""
 msgstr ""
 "Project-Id-Version: PACKAGE VERSION\n"
-"POT-Creation-Date: 1999-09-20 09:21-0400\n"
+"POT-Creation-Date: 1999-09-20 23:21-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"
@@ -14,110 +14,110 @@ msgstr ""
 "Content-Type: text/plain; charset=CHARSET\n"
 "Content-Transfer-Encoding: ENCODING\n"
 
-#: ../build.c:24 ../lib/rpminstall.c:222 ../lib/rpminstall.c:374
+#: ../build.c:23 ../lib/rpminstall.c:222 ../lib/rpminstall.c:382
 #, c-format
 msgid "cannot open %s/packages.rpm\n"
 msgstr ""
 
-#: ../build.c:34
+#: ../build.c:33
 msgid "failed build dependencies:\n"
 msgstr ""
 
-#: ../build.c:62
+#: ../build.c:61
 #, c-format
 msgid "Unable to open spec file: %s\n"
 msgstr ""
 
-#: ../build.c:118 ../build.c:131
+#: ../build.c:117 ../build.c:130
 #, c-format
 msgid "Failed to open tar pipe: %s\n"
 msgstr ""
 
 #. Give up
-#: ../build.c:139
+#: ../build.c:138
 #, c-format
 msgid "Failed to read spec file from %s\n"
 msgstr ""
 
-#: ../build.c:164
+#: ../build.c:163
 #, c-format
 msgid "Failed to rename %s to %s: %s\n"
 msgstr ""
 
-#: ../build.c:202
+#: ../build.c:201
 #, c-format
 msgid "File is not a regular file: %s\n"
 msgstr ""
 
-#: ../build.c:208
+#: ../build.c:207
 #, c-format
 msgid "File %s does not appear to be a specfile.\n"
 msgstr ""
 
 #. parse up the build operators
-#: ../build.c:259
+#: ../build.c:258
 #, c-format
 msgid "Building target platforms: %s\n"
 msgstr ""
 
-#: ../build.c:268
+#: ../build.c:267
 #, c-format
 msgid "Building for target %s\n"
 msgstr ""
 
-#: ../build.c:312
+#: ../build.c:311
 msgid "buildroot already specified"
 msgstr ""
 
-#: ../build.c:318
+#: ../build.c:317
 msgid "--buildarch has been obsoleted.  Use the --target option instead.\n"
 msgstr ""
 
-#: ../build.c:322
+#: ../build.c:321
 msgid "--buildos has been obsoleted.  Use the --target option instead.\n"
 msgstr ""
 
-#: ../build.c:343
+#: ../build.c:342
 msgid "override build architecture"
 msgstr ""
 
-#: ../build.c:345
+#: ../build.c:344
 msgid "override build operating system"
 msgstr ""
 
-#: ../build.c:347
+#: ../build.c:346
 msgid "override build root"
 msgstr ""
 
-#: ../build.c:349 ../rpm.c:457
+#: ../build.c:348 ../rpm.c:456
 msgid "remove build tree when done"
 msgstr ""
 
-#: ../build.c:351
+#: ../build.c:350
 msgid "do not execute any stages of the build"
 msgstr ""
 
-#: ../build.c:353
+#: ../build.c:352
 msgid "do not accept I18N msgstr's from specfile"
 msgstr ""
 
-#: ../build.c:355
+#: ../build.c:354
 msgid "remove sources when done"
 msgstr ""
 
-#: ../build.c:357
+#: ../build.c:356
 msgid "remove specfile when done"
 msgstr ""
 
-#: ../build.c:359 ../rpm.c:455
+#: ../build.c:358 ../rpm.c:454
 msgid "skip straight to specified stage (only for c,i)"
 msgstr ""
 
-#: ../build.c:361
+#: ../build.c:360
 msgid "override target platform"
 msgstr ""
 
-#: ../build.c:363
+#: ../build.c:362
 msgid "lookup I18N strings in specfile catalog"
 msgstr ""
 
@@ -163,1056 +163,1056 @@ msgstr ""
 msgid "no copyright!\n"
 msgstr ""
 
-#: ../rpm.c:159
+#: ../rpm.c:158
 #, c-format
 msgid "rpm: %s\n"
 msgstr ""
 
-#: ../rpm.c:170
+#: ../rpm.c:169
 #, c-format
 msgid "RPM version %s\n"
 msgstr ""
 
-#: ../rpm.c:174
+#: ../rpm.c:173
 msgid "Copyright (C) 1998 - Red Hat Software"
 msgstr ""
 
-#: ../rpm.c:175
+#: ../rpm.c:174
 msgid "This may be freely redistributed under the terms of the GNU GPL"
 msgstr ""
 
-#: ../rpm.c:183
+#: ../rpm.c:182
 msgid "usage: rpm {--help}"
 msgstr ""
 
-#: ../rpm.c:184
+#: ../rpm.c:183
 msgid "       rpm {--version}"
 msgstr ""
 
-#: ../rpm.c:185
+#: ../rpm.c:184
 msgid "       rpm {--initdb}   [--dbpath <dir>]"
 msgstr ""
 
-#: ../rpm.c:186
+#: ../rpm.c:185
 msgid ""
 "       rpm {--install -i} [-v] [--hash -h] [--percent] [--force] [--test]"
 msgstr ""
 
-#: ../rpm.c:187
+#: ../rpm.c:186
 msgid "                        [--replacepkgs] [--replacefiles] [--root <dir>]"
 msgstr ""
 
-#: ../rpm.c:188
+#: ../rpm.c:187
 msgid "                        [--excludedocs] [--includedocs] [--noscripts]"
 msgstr ""
 
-#: ../rpm.c:189
+#: ../rpm.c:188
 msgid ""
 "                        [--rcfile <file>] [--ignorearch] [--dbpath <dir>]"
 msgstr ""
 
-#: ../rpm.c:190
+#: ../rpm.c:189
 msgid ""
 "                        [--prefix <dir>] [--ignoreos] [--nodeps] [--allfiles]"
 msgstr ""
 
-#: ../rpm.c:191
+#: ../rpm.c:190
 msgid ""
 "                        [--ftpproxy <host>] [--ftpport <port>] [--justdb]"
 msgstr ""
 
-#: ../rpm.c:192 ../rpm.c:201 ../rpm.c:210
+#: ../rpm.c:191 ../rpm.c:200 ../rpm.c:209
 msgid "                        [--httpproxy <host>] [--httpport <port>] "
 msgstr ""
 
-#: ../rpm.c:193 ../rpm.c:203
+#: ../rpm.c:192 ../rpm.c:202
 msgid "                        [--noorder] [--relocate oldpath=newpath]"
 msgstr ""
 
-#: ../rpm.c:194
+#: ../rpm.c:193
 msgid ""
 "                        [--badreloc] [--notriggers] [--excludepath <path>]"
 msgstr ""
 
-#: ../rpm.c:195
+#: ../rpm.c:194
 msgid "                        [--ignoresize] file1.rpm ... fileN.rpm"
 msgstr ""
 
-#: ../rpm.c:196
+#: ../rpm.c:195
 msgid ""
 "       rpm {--upgrade -U} [-v] [--hash -h] [--percent] [--force] [--test]"
 msgstr ""
 
-#: ../rpm.c:197
+#: ../rpm.c:196
 msgid "                        [--oldpackage] [--root <dir>] [--noscripts]"
 msgstr ""
 
-#: ../rpm.c:198
+#: ../rpm.c:197
 msgid ""
 "                        [--excludedocs] [--includedocs] [--rcfile <file>]"
 msgstr ""
 
-#: ../rpm.c:199
+#: ../rpm.c:198
 msgid ""
 "                        [--ignorearch]  [--dbpath <dir>] [--prefix <dir>] "
 msgstr ""
 
-#: ../rpm.c:200
+#: ../rpm.c:199
 msgid "                        [--ftpproxy <host>] [--ftpport <port>]"
 msgstr ""
 
-#: ../rpm.c:202
+#: ../rpm.c:201
 msgid "                        [--ignoreos] [--nodeps] [--allfiles] [--justdb]"
 msgstr ""
 
-#: ../rpm.c:204
+#: ../rpm.c:203
 msgid ""
 "                        [--badreloc] [--excludepath <path>] [--ignoresize]"
 msgstr ""
 
-#: ../rpm.c:205
+#: ../rpm.c:204
 msgid "                        file1.rpm ... fileN.rpm"
 msgstr ""
 
-#: ../rpm.c:206
+#: ../rpm.c:205
 msgid "       rpm {--query -q} [-afpg] [-i] [-l] [-s] [-d] [-c] [-v] [-R]"
 msgstr ""
 
-#: ../rpm.c:207
+#: ../rpm.c:206
 msgid "                        [--scripts] [--root <dir>] [--rcfile <file>]"
 msgstr ""
 
-#: ../rpm.c:208
+#: ../rpm.c:207
 msgid "                        [--whatprovides] [--whatrequires] [--requires]"
 msgstr ""
 
-#: ../rpm.c:209
+#: ../rpm.c:208
 msgid ""
 "                        [--triggeredby] [--ftpuseport] [--ftpproxy <host>]"
 msgstr ""
 
-#: ../rpm.c:211
+#: ../rpm.c:210
 msgid ""
 "                        [--ftpport <port>] [--provides] [--triggers] [--dump]"
 msgstr ""
 
-#: ../rpm.c:212
+#: ../rpm.c:211
 msgid "                        [--changelog] [--dbpath <dir>] [targets]"
 msgstr ""
 
-#: ../rpm.c:213
+#: ../rpm.c:212
 msgid "       rpm {--verify -V -y} [-afpg] [--root <dir>] [--rcfile <file>]"
 msgstr ""
 
-#: ../rpm.c:214
+#: ../rpm.c:213
 msgid ""
 "                        [--dbpath <dir>] [--nodeps] [--nofiles] [--noscripts]"
 msgstr ""
 
-#: ../rpm.c:215
+#: ../rpm.c:214
 msgid "                        [--nomd5] [targets]"
 msgstr ""
 
-#: ../rpm.c:216
+#: ../rpm.c:215
 msgid "       rpm {--setperms} [-afpg] [target]"
 msgstr ""
 
-#: ../rpm.c:217
+#: ../rpm.c:216
 msgid "       rpm {--setugids} [-afpg] [target]"
 msgstr ""
 
-#: ../rpm.c:218
+#: ../rpm.c:217
 msgid "       rpm {--freshen -F} file1.rpm ... fileN.rpm"
 msgstr ""
 
-#: ../rpm.c:219
+#: ../rpm.c:218
 msgid "       rpm {--erase -e} [--root <dir>] [--noscripts] [--rcfile <file>]"
 msgstr ""
 
-#: ../rpm.c:220
+#: ../rpm.c:219
 msgid "                        [--dbpath <dir>] [--nodeps] [--allmatches]"
 msgstr ""
 
-#: ../rpm.c:221
+#: ../rpm.c:220
 msgid ""
 "                        [--justdb] [--notriggers] rpackage1 ... packageN"
 msgstr ""
 
-#: ../rpm.c:222
+#: ../rpm.c:221
 msgid ""
 "       rpm {-b|t}[plciba] [-v] [--short-circuit] [--clean] [--rcfile  <file>]"
 msgstr ""
 
-#: ../rpm.c:223
+#: ../rpm.c:222
 msgid "                        [--sign] [--nobuild] [--timecheck <s>] ]"
 msgstr ""
 
-#: ../rpm.c:224
+#: ../rpm.c:223
 msgid "                        [--target=platform1[,platform2...]]"
 msgstr ""
 
-#: ../rpm.c:225
+#: ../rpm.c:224
 msgid "                        [--rmsource] specfile"
 msgstr ""
 
-#: ../rpm.c:226
+#: ../rpm.c:225
 msgid "       rpm {--rmsource} [--rcfile <file>] [-v] specfile"
 msgstr ""
 
-#: ../rpm.c:227
+#: ../rpm.c:226
 msgid ""
 "       rpm {--rebuild} [--rcfile <file>] [-v] source1.rpm ... sourceN.rpm"
 msgstr ""
 
-#: ../rpm.c:228
+#: ../rpm.c:227
 msgid ""
 "       rpm {--recompile} [--rcfile <file>] [-v] source1.rpm ... sourceN.rpm"
 msgstr ""
 
-#: ../rpm.c:229
+#: ../rpm.c:228
 msgid "       rpm {--resign} [--rcfile <file>] package1 package2 ... packageN"
 msgstr ""
 
-#: ../rpm.c:230
+#: ../rpm.c:229
 msgid "       rpm {--addsign} [--rcfile <file>] package1 package2 ... packageN"
 msgstr ""
 
-#: ../rpm.c:231
+#: ../rpm.c:230
 msgid ""
 "       rpm {--checksig -K} [--nopgp] [--nogpg] [--nomd5] [--rcfile <file>]"
 msgstr ""
 
-#: ../rpm.c:232
+#: ../rpm.c:231
 msgid "                           package1 ... packageN"
 msgstr ""
 
-#: ../rpm.c:233
+#: ../rpm.c:232
 msgid "       rpm {--rebuilddb} [--rcfile <file>] [--dbpath <dir>]"
 msgstr ""
 
-#: ../rpm.c:234
+#: ../rpm.c:233
 msgid "       rpm {--querytags}"
 msgstr ""
 
-#: ../rpm.c:268
+#: ../rpm.c:267
 msgid "usage:"
 msgstr ""
 
-#: ../rpm.c:270
+#: ../rpm.c:269
 msgid "print this message"
 msgstr ""
 
-#: ../rpm.c:272
+#: ../rpm.c:271
 msgid "print the version of rpm being used"
 msgstr ""
 
-#: ../rpm.c:273
+#: ../rpm.c:272
 msgid "   all modes support the following arguments:"
 msgstr ""
 
-#: ../rpm.c:274
+#: ../rpm.c:273
 msgid "      --rcfile <file>     "
 msgstr ""
 
-#: ../rpm.c:275
+#: ../rpm.c:274
 msgid "use <file> instead of /etc/rpmrc and $HOME/.rpmrc"
 msgstr ""
 
-#: ../rpm.c:277
+#: ../rpm.c:276
 msgid "be a little more verbose"
 msgstr ""
 
-#: ../rpm.c:279
+#: ../rpm.c:278
 msgid "be incredibly verbose (for debugging)"
 msgstr ""
 
-#: ../rpm.c:281
+#: ../rpm.c:280
 msgid "query mode"
 msgstr ""
 
-#: ../rpm.c:282 ../rpm.c:344 ../rpm.c:408 ../rpm.c:436
+#: ../rpm.c:281 ../rpm.c:343 ../rpm.c:407 ../rpm.c:435
 msgid "      --root <dir>        "
 msgstr ""
 
-#: ../rpm.c:283 ../rpm.c:345 ../rpm.c:409 ../rpm.c:437 ../rpm.c:499
+#: ../rpm.c:282 ../rpm.c:344 ../rpm.c:408 ../rpm.c:436 ../rpm.c:498
 msgid "use <dir> as the top level directory"
 msgstr ""
 
-#: ../rpm.c:284 ../rpm.c:342 ../rpm.c:372 ../rpm.c:424 ../rpm.c:496
+#: ../rpm.c:283 ../rpm.c:341 ../rpm.c:371 ../rpm.c:423 ../rpm.c:495
 msgid "      --dbpath <dir>      "
 msgstr ""
 
-#: ../rpm.c:285 ../rpm.c:343 ../rpm.c:373 ../rpm.c:425 ../rpm.c:497
+#: ../rpm.c:284 ../rpm.c:342 ../rpm.c:372 ../rpm.c:424 ../rpm.c:496
 msgid "use <dir> as the directory for the database"
 msgstr ""
 
-#: ../rpm.c:286
+#: ../rpm.c:285
 msgid "      --queryformat <qfmt>"
 msgstr ""
 
-#: ../rpm.c:287
+#: ../rpm.c:286
 msgid "use <qfmt> as the header format (implies -i)"
 msgstr ""
 
-#: ../rpm.c:288
+#: ../rpm.c:287
 msgid ""
 "   install, upgrade and query (with -p) allow ftp URL's to be used in place"
 msgstr ""
 
-#: ../rpm.c:289
+#: ../rpm.c:288
 msgid "   of file names as well as the following options:"
 msgstr ""
 
-#: ../rpm.c:290
+#: ../rpm.c:289
 msgid "      --ftpproxy <host>   "
 msgstr ""
 
-#: ../rpm.c:291
+#: ../rpm.c:290
 msgid "hostname or IP of ftp proxy"
 msgstr ""
 
-#: ../rpm.c:292
+#: ../rpm.c:291
 msgid "      --ftpport <port>    "
 msgstr ""
 
-#: ../rpm.c:293
+#: ../rpm.c:292
 msgid "port number of ftp server (or proxy)"
 msgstr ""
 
-#: ../rpm.c:294
+#: ../rpm.c:293
 msgid "      --httpproxy <host>   "
 msgstr ""
 
-#: ../rpm.c:295
+#: ../rpm.c:294
 msgid "hostname or IP of http proxy"
 msgstr ""
 
-#: ../rpm.c:296
+#: ../rpm.c:295
 msgid "      --httpport <port>    "
 msgstr ""
 
-#: ../rpm.c:297
+#: ../rpm.c:296
 msgid "port number of http server (or proxy)"
 msgstr ""
 
-#: ../rpm.c:298
+#: ../rpm.c:297
 msgid "      Package specification options:"
 msgstr ""
 
-#: ../rpm.c:300
+#: ../rpm.c:299
 msgid "query all packages"
 msgstr ""
 
-#: ../rpm.c:301
+#: ../rpm.c:300
 msgid "        -f <file>+        "
 msgstr ""
 
-#: ../rpm.c:302
+#: ../rpm.c:301
 msgid "query package owning <file>"
 msgstr ""
 
-#: ../rpm.c:303
+#: ../rpm.c:302
 msgid "        -p <packagefile>+ "
 msgstr ""
 
-#: ../rpm.c:304
+#: ../rpm.c:303
 msgid "query (uninstalled) package <packagefile>"
 msgstr ""
 
-#: ../rpm.c:305
+#: ../rpm.c:304
 msgid "        --triggeredby <pkg>"
 msgstr ""
 
-#: ../rpm.c:306
+#: ../rpm.c:305
 msgid "query packages triggered by <pkg>"
 msgstr ""
 
-#: ../rpm.c:307
+#: ../rpm.c:306
 msgid "        --whatprovides <cap>"
 msgstr ""
 
-#: ../rpm.c:308
+#: ../rpm.c:307
 msgid "query packages which provide <cap> capability"
 msgstr ""
 
-#: ../rpm.c:309
+#: ../rpm.c:308
 msgid "        --whatrequires <cap>"
 msgstr ""
 
-#: ../rpm.c:310
+#: ../rpm.c:309
 msgid "query packages which require <cap> capability"
 msgstr ""
 
-#: ../rpm.c:311
+#: ../rpm.c:310
 msgid "      Information selection options:"
 msgstr ""
 
-#: ../rpm.c:313
+#: ../rpm.c:312
 msgid "display package information"
 msgstr ""
 
-#: ../rpm.c:315
+#: ../rpm.c:314
 msgid "display the package's change log"
 msgstr ""
 
-#: ../rpm.c:317
+#: ../rpm.c:316
 msgid "display package file list"
 msgstr ""
 
-#: ../rpm.c:319
+#: ../rpm.c:318
 msgid "show file states (implies -l)"
 msgstr ""
 
-#: ../rpm.c:321
+#: ../rpm.c:320
 msgid "list only documentation files (implies -l)"
 msgstr ""
 
-#: ../rpm.c:323
+#: ../rpm.c:322
 msgid "list only configuration files (implies -l)"
 msgstr ""
 
-#: ../rpm.c:325
+#: ../rpm.c:324
 msgid ""
 "show all verifiable information for each file (must be used with -l, -c, or "
 "-d)"
 msgstr ""
 
-#: ../rpm.c:327
+#: ../rpm.c:326
 msgid "list capabilities package provides"
 msgstr ""
 
-#: ../rpm.c:328
+#: ../rpm.c:327
 msgid "        --requires"
 msgstr ""
 
-#: ../rpm.c:330
+#: ../rpm.c:329
 msgid "list package dependencies"
 msgstr ""
 
-#: ../rpm.c:332
+#: ../rpm.c:331
 msgid "print the various [un]install scripts"
 msgstr ""
 
-#: ../rpm.c:334
+#: ../rpm.c:333
 msgid "show the trigger scripts contained in the package"
 msgstr ""
 
-#: ../rpm.c:338
+#: ../rpm.c:337
 msgid "    --pipe <cmd>          "
 msgstr ""
 
-#: ../rpm.c:339
+#: ../rpm.c:338
 msgid "send stdout to <cmd>"
 msgstr ""
 
-#: ../rpm.c:341
+#: ../rpm.c:340
 msgid ""
 "verify a package installation using the same same package specification "
 "options as -q"
 msgstr ""
 
-#: ../rpm.c:347 ../rpm.c:395 ../rpm.c:429
+#: ../rpm.c:346 ../rpm.c:394 ../rpm.c:428
 msgid "do not verify package dependencies"
 msgstr ""
 
-#: ../rpm.c:349
+#: ../rpm.c:348
 msgid "do not verify file md5 checksums"
 msgstr ""
 
-#: ../rpm.c:351
+#: ../rpm.c:350
 msgid "do not verify file attributes"
 msgstr ""
 
-#: ../rpm.c:354
+#: ../rpm.c:353
 msgid ""
 "set the file permissions to those in the package database using the same "
 "package specification options as -q"
 msgstr ""
 
-#: ../rpm.c:357
+#: ../rpm.c:356
 msgid ""
 "set the file owner and group to those in the package database using the same "
 "package specification options as -q"
 msgstr ""
 
-#: ../rpm.c:361
+#: ../rpm.c:360
 msgid "    --install <packagefile>"
 msgstr ""
 
-#: ../rpm.c:362
+#: ../rpm.c:361
 msgid "    -i <packagefile>      "
 msgstr ""
 
-#: ../rpm.c:363
+#: ../rpm.c:362
 msgid "install package"
 msgstr ""
 
-#: ../rpm.c:364
+#: ../rpm.c:363
 msgid "      --excludepath <path>"
 msgstr ""
 
-#: ../rpm.c:365
+#: ../rpm.c:364
 msgid "skip files in path <path>"
 msgstr ""
 
-#: ../rpm.c:366
+#: ../rpm.c:365
 msgid "      --relocate <oldpath>=<newpath>"
 msgstr ""
 
-#: ../rpm.c:367
+#: ../rpm.c:366
 msgid "relocate files from <oldpath> to <newpath>"
 msgstr ""
 
-#: ../rpm.c:369
+#: ../rpm.c:368
 msgid "relocate files even though the package doesn't allow it"
 msgstr ""
 
-#: ../rpm.c:370
+#: ../rpm.c:369
 msgid "      --prefix <dir>      "
 msgstr ""
 
-#: ../rpm.c:371
+#: ../rpm.c:370
 msgid "relocate the package to <dir>, if relocatable"
 msgstr ""
 
-#: ../rpm.c:375
+#: ../rpm.c:374
 msgid "do not install documentation"
 msgstr ""
 
-#: ../rpm.c:377
+#: ../rpm.c:376
 msgid "short hand for --replacepkgs --replacefiles"
 msgstr ""
 
-#: ../rpm.c:380
+#: ../rpm.c:379
 msgid "print hash marks as package installs (good with -v)"
 msgstr ""
 
-#: ../rpm.c:382
+#: ../rpm.c:381
 msgid "install all files, even configurations which might otherwise be skipped"
 msgstr ""
 
-#: ../rpm.c:385
+#: ../rpm.c:384
 msgid "don't verify package architecture"
 msgstr ""
 
-#: ../rpm.c:387
+#: ../rpm.c:386
 msgid "don't check disk space before installing"
 msgstr ""
 
-#: ../rpm.c:389
+#: ../rpm.c:388
 msgid "don't verify package operating system"
 msgstr ""
 
-#: ../rpm.c:391
+#: ../rpm.c:390
 msgid "install documentation"
 msgstr ""
 
-#: ../rpm.c:393 ../rpm.c:427
+#: ../rpm.c:392 ../rpm.c:426
 msgid "update the database, but do not modify the filesystem"
 msgstr ""
 
-#: ../rpm.c:397 ../rpm.c:431
+#: ../rpm.c:396 ../rpm.c:430
 msgid "do not reorder package installation to satisfy dependencies"
 msgstr ""
 
-#: ../rpm.c:399
+#: ../rpm.c:398
 msgid "don't execute any installation scripts"
 msgstr ""
 
-#: ../rpm.c:401 ../rpm.c:435
+#: ../rpm.c:400 ../rpm.c:434
 msgid "don't execute any scripts triggered by this package"
 msgstr ""
 
-#: ../rpm.c:403
+#: ../rpm.c:402
 msgid "print percentages as package installs"
 msgstr ""
 
-#: ../rpm.c:405
+#: ../rpm.c:404
 msgid "install even if the package replaces installed files"
 msgstr ""
 
-#: ../rpm.c:407
+#: ../rpm.c:406
 msgid "reinstall if the package is already present"
 msgstr ""
 
-#: ../rpm.c:411
+#: ../rpm.c:410
 msgid "don't install, but tell if it would work or not"
 msgstr ""
 
-#: ../rpm.c:413
+#: ../rpm.c:412
 msgid "    --upgrade <packagefile>"
 msgstr ""
 
-#: ../rpm.c:414
+#: ../rpm.c:413
 msgid "    -U <packagefile>      "
 msgstr ""
 
-#: ../rpm.c:415
+#: ../rpm.c:414
 msgid "upgrade package (same options as --install, plus)"
 msgstr ""
 
-#: ../rpm.c:417
+#: ../rpm.c:416
 msgid ""
 "upgrade to an old version of the package (--force on upgrades does this "
 "automatically)"
 msgstr ""
 
-#: ../rpm.c:419
+#: ../rpm.c:418
 msgid "    --erase <package>"
 msgstr ""
 
-#: ../rpm.c:421
+#: ../rpm.c:420
 msgid "erase (uninstall) package"
 msgstr ""
 
-#: ../rpm.c:423
+#: ../rpm.c:422
 msgid ""
 "remove all packages which match <package> (normally an error is generated if "
 "<package> specified multiple packages)"
 msgstr ""
 
-#: ../rpm.c:433
+#: ../rpm.c:432
 msgid "do not execute any package specific scripts"
 msgstr ""
 
-#: ../rpm.c:439
+#: ../rpm.c:438
 msgid "    -b<stage> <spec>      "
 msgstr ""
 
-#: ../rpm.c:440
+#: ../rpm.c:439
 msgid "    -t<stage> <tarball>   "
 msgstr ""
 
-#: ../rpm.c:441
+#: ../rpm.c:440
 msgid "build package, where <stage> is one of:"
 msgstr ""
 
-#: ../rpm.c:443
+#: ../rpm.c:442
 msgid "prep (unpack sources and apply patches)"
 msgstr ""
 
-#: ../rpm.c:445
+#: ../rpm.c:444
 #, c-format
 msgid "list check (do some cursory checks on %files)"
 msgstr ""
 
-#: ../rpm.c:447
+#: ../rpm.c:446
 msgid "compile (prep and compile)"
 msgstr ""
 
-#: ../rpm.c:449
+#: ../rpm.c:448
 msgid "install (prep, compile, install)"
 msgstr ""
 
-#: ../rpm.c:451
+#: ../rpm.c:450
 msgid "binary package (prep, compile, install, package)"
 msgstr ""
 
-#: ../rpm.c:453
+#: ../rpm.c:452
 msgid "bin/src package (prep, compile, install, package)"
 msgstr ""
 
-#: ../rpm.c:459
+#: ../rpm.c:458
 msgid "remove sources and spec file when done"
 msgstr ""
 
-#: ../rpm.c:461
+#: ../rpm.c:460
 msgid "generate PGP/GPG signature"
 msgstr ""
 
-#: ../rpm.c:462
+#: ../rpm.c:461
 msgid "      --buildroot <dir>   "
 msgstr ""
 
-#: ../rpm.c:463
+#: ../rpm.c:462
 msgid "use <dir> as the build root"
 msgstr ""
 
-#: ../rpm.c:464
+#: ../rpm.c:463
 msgid "      --target=<platform>+"
 msgstr ""
 
-#: ../rpm.c:465
+#: ../rpm.c:464
 msgid "build the packages for the build targets platform1...platformN."
 msgstr ""
 
-#: ../rpm.c:467
+#: ../rpm.c:466
 msgid "do not execute any stages"
 msgstr ""
 
-#: ../rpm.c:468
+#: ../rpm.c:467
 msgid "      --timecheck <secs>  "
 msgstr ""
 
-#: ../rpm.c:469
+#: ../rpm.c:468
 msgid "set the time check to <secs> seconds (0 disables)"
 msgstr ""
 
-#: ../rpm.c:471
+#: ../rpm.c:470
 msgid "    --rebuild <src_pkg>   "
 msgstr ""
 
-#: ../rpm.c:472
+#: ../rpm.c:471
 msgid ""
 "install source package, build binary package and remove spec file, sources, "
 "patches, and icons."
 msgstr ""
 
-#: ../rpm.c:473
+#: ../rpm.c:472
 msgid "    --rmsource <spec>     "
 msgstr ""
 
-#: ../rpm.c:474
+#: ../rpm.c:473
 msgid "remove sources and spec file"
 msgstr ""
 
-#: ../rpm.c:475
+#: ../rpm.c:474
 msgid "    --recompile <src_pkg> "
 msgstr ""
 
-#: ../rpm.c:476
+#: ../rpm.c:475
 msgid "like --rebuild, but don't build any package"
 msgstr ""
 
-#: ../rpm.c:477
+#: ../rpm.c:476
 msgid "    --resign <pkg>+       "
 msgstr ""
 
-#: ../rpm.c:478
+#: ../rpm.c:477
 msgid "sign a package (discard current signature)"
 msgstr ""
 
-#: ../rpm.c:479
+#: ../rpm.c:478
 msgid "    --addsign <pkg>+      "
 msgstr ""
 
-#: ../rpm.c:480
+#: ../rpm.c:479
 msgid "add a signature to a package"
 msgstr ""
 
-#: ../rpm.c:482
+#: ../rpm.c:481
 msgid "    --checksig <pkg>+     "
 msgstr ""
 
-#: ../rpm.c:483
+#: ../rpm.c:482
 msgid "verify package signature"
 msgstr ""
 
-#: ../rpm.c:485
+#: ../rpm.c:484
 msgid "skip any PGP signatures"
 msgstr ""
 
-#: ../rpm.c:487
+#: ../rpm.c:486
 msgid "skip any GPG signatures"
 msgstr ""
 
-#: ../rpm.c:489
+#: ../rpm.c:488
 msgid "skip any MD5 signatures"
 msgstr ""
 
-#: ../rpm.c:491
+#: ../rpm.c:490
 msgid "list the tags that can be used in a query format"
 msgstr ""
 
-#: ../rpm.c:493
+#: ../rpm.c:492
 msgid "make sure a valid database exists"
 msgstr ""
 
-#: ../rpm.c:495
+#: ../rpm.c:494
 msgid "rebuild database from existing database"
 msgstr ""
 
-#: ../rpm.c:638 ../rpm.c:644 ../rpm.c:651 ../rpm.c:657 ../rpm.c:666
-#: ../rpm.c:673 ../rpm.c:720 ../rpm.c:726 ../rpm.c:760 ../rpm.c:766
-#: ../rpm.c:772 ../rpm.c:780 ../rpm.c:815 ../rpm.c:870 ../rpm.c:877
+#: ../rpm.c:637 ../rpm.c:643 ../rpm.c:650 ../rpm.c:656 ../rpm.c:665
+#: ../rpm.c:672 ../rpm.c:719 ../rpm.c:725 ../rpm.c:759 ../rpm.c:765
+#: ../rpm.c:771 ../rpm.c:779 ../rpm.c:814 ../rpm.c:869 ../rpm.c:876
 msgid "only one major mode may be specified"
 msgstr ""
 
-#: ../rpm.c:659
+#: ../rpm.c:658
 msgid "-u and --uninstall are deprecated and no longer work.\n"
 msgstr ""
 
-#: ../rpm.c:661
+#: ../rpm.c:660
 msgid "Use -e or --erase instead.\n"
 msgstr ""
 
-#: ../rpm.c:677
+#: ../rpm.c:676
 msgid "--build (-b) requires one of a,b,i,c,p,l as its sole argument"
 msgstr ""
 
-#: ../rpm.c:681
+#: ../rpm.c:680
 msgid "--tarbuild (-t) requires one of a,b,i,c,p,l as its sole argument"
 msgstr ""
 
-#: ../rpm.c:733 ../rpm.c:739 ../rpm.c:746 ../rpm.c:753 ../rpm.c:884
+#: ../rpm.c:732 ../rpm.c:738 ../rpm.c:745 ../rpm.c:752 ../rpm.c:883
 msgid "one type of query/verify may be performed at a time"
 msgstr ""
 
-#: ../rpm.c:788
+#: ../rpm.c:787
 msgid "arguments to --dbpath must begin with a /"
 msgstr ""
 
-#: ../rpm.c:821
+#: ../rpm.c:820
 msgid "relocations must begin with a /"
 msgstr ""
 
-#: ../rpm.c:823
+#: ../rpm.c:822
 msgid "relocations must contain a ="
 msgstr ""
 
-#: ../rpm.c:826
+#: ../rpm.c:825
 msgid "relocations must have a / following the ="
 msgstr ""
 
-#: ../rpm.c:835
+#: ../rpm.c:834
 msgid "exclude paths must begin with a /"
 msgstr ""
 
-#: ../rpm.c:844
+#: ../rpm.c:843
 #, c-format
 msgid "Internal error in argument processing (%d) :-(\n"
 msgstr ""
 
-#: ../rpm.c:897
+#: ../rpm.c:896
 msgid "--dbpath given for operation that does not use a database"
 msgstr ""
 
-#: ../rpm.c:902
+#: ../rpm.c:901
 msgid "--timecheck may only be used during package builds"
 msgstr ""
 
-#: ../rpm.c:905
+#: ../rpm.c:904
 msgid "unexpected query flags"
 msgstr ""
 
-#: ../rpm.c:908
+#: ../rpm.c:907
 msgid "unexpected query format"
 msgstr ""
 
-#: ../rpm.c:912
+#: ../rpm.c:911
 msgid "unexpected query source"
 msgstr ""
 
-#: ../rpm.c:918
+#: ../rpm.c:917
 msgid "only installation, upgrading, rmsource and rmspec may be forced"
 msgstr ""
 
-#: ../rpm.c:921
+#: ../rpm.c:920
 msgid "files may only be relocated during package installation"
 msgstr ""
 
-#: ../rpm.c:924
+#: ../rpm.c:923
 msgid "only one of --prefix or --relocate may be used"
 msgstr ""
 
-#: ../rpm.c:927
+#: ../rpm.c:926
 msgid ""
 "--relocate and --excludepath may only be used when installing new packages"
 msgstr ""
 
-#: ../rpm.c:930
+#: ../rpm.c:929
 msgid "--prefix may only be used when installing new packages"
 msgstr ""
 
-#: ../rpm.c:933
+#: ../rpm.c:932
 msgid "arguments to --prefix must begin with a /"
 msgstr ""
 
-#: ../rpm.c:936
+#: ../rpm.c:935
 msgid "--hash (-h) may only be specified during package installation"
 msgstr ""
 
-#: ../rpm.c:940
+#: ../rpm.c:939
 msgid "--percent may only be specified during package installation"
 msgstr ""
 
-#: ../rpm.c:944
+#: ../rpm.c:943
 msgid "--replacefiles may only be specified during package installation"
 msgstr ""
 
-#: ../rpm.c:948
+#: ../rpm.c:947
 msgid "--replacepkgs may only be specified during package installation"
 msgstr ""
 
-#: ../rpm.c:952
+#: ../rpm.c:951
 msgid "--excludedocs may only be specified during package installation"
 msgstr ""
 
-#: ../rpm.c:956
+#: ../rpm.c:955
 msgid "--includedocs may only be specified during package installation"
 msgstr ""
 
-#: ../rpm.c:960
+#: ../rpm.c:959
 msgid "only one of --excludedocs and --includedocs may be specified"
 msgstr ""
 
-#: ../rpm.c:964
+#: ../rpm.c:963
 msgid "--ignorearch may only be specified during package installation"
 msgstr ""
 
-#: ../rpm.c:968
+#: ../rpm.c:967
 msgid "--ignoreos may only be specified during package installation"
 msgstr ""
 
-#: ../rpm.c:972
+#: ../rpm.c:971
 msgid "--ignoresize may only be specified during package installation"
 msgstr ""
 
-#: ../rpm.c:976
+#: ../rpm.c:975
 msgid "--allmatches may only be specified during package erasure"
 msgstr ""
 
-#: ../rpm.c:980
+#: ../rpm.c:979
 msgid "--allfiles may only be specified during package installation"
 msgstr ""
 
-#: ../rpm.c:984
+#: ../rpm.c:983
 msgid "--justdb may only be specified during package installation and erasure"
 msgstr ""
 
-#: ../rpm.c:989
+#: ../rpm.c:988
 msgid ""
 "--noscripts may only be specified during package installation, erasure, and "
 "verification"
 msgstr ""
 
-#: ../rpm.c:993
+#: ../rpm.c:992
 msgid ""
 "--notriggers may only be specified during package installation, erasure, and "
 "verification"
 msgstr ""
 
-#: ../rpm.c:999
+#: ../rpm.c:998
 msgid ""
 "--nodeps may only be specified during package building, installation, "
 "erasure, and verification"
 msgstr ""
 
-#: ../rpm.c:1004
+#: ../rpm.c:1003
 msgid ""
 "--test may only be specified during package installation, erasure, and "
 "building"
 msgstr ""
 
-#: ../rpm.c:1009
+#: ../rpm.c:1008
 msgid ""
 "--root (-r) may only be specified during installation, erasure, querying, "
 "and database rebuilds"
 msgstr ""
 
-#: ../rpm.c:1014
+#: ../rpm.c:1013
 msgid "arguments to --root (-r) must begin with a /"
 msgstr ""
 
-#: ../rpm.c:1017
+#: ../rpm.c:1016
 msgid "--oldpackage may only be used during upgrades"
 msgstr ""
 
-#: ../rpm.c:1022
+#: ../rpm.c:1021
 msgid ""
 "ftp options can only be used during package queries, installs, and upgrades"
 msgstr ""
 
-#: ../rpm.c:1028
+#: ../rpm.c:1027
 msgid ""
 "http options can only be used during package queries, installs, and upgrades"
 msgstr ""
 
-#: ../rpm.c:1032
+#: ../rpm.c:1031
 msgid "--nopgp may only be used during signature checking"
 msgstr ""
 
-#: ../rpm.c:1035
+#: ../rpm.c:1034
 msgid "--nogpg may only be used during signature checking"
 msgstr ""
 
-#: ../rpm.c:1038
+#: ../rpm.c:1037
 msgid ""
 "--nomd5 may only be used during signature checking and package verification"
 msgstr ""
 
-#: ../rpm.c:1062
+#: ../rpm.c:1061
 msgid "no files to sign\n"
 msgstr ""
 
-#: ../rpm.c:1067
+#: ../rpm.c:1066
 #, c-format
 msgid "cannot access file %s\n"
 msgstr ""
 
-#: ../rpm.c:1082
+#: ../rpm.c:1081
 msgid "pgp not found: "
 msgstr ""
 
-#: ../rpm.c:1086
+#: ../rpm.c:1085
 msgid "Enter pass phrase: "
 msgstr ""
 
-#: ../rpm.c:1088
+#: ../rpm.c:1087
 msgid "Pass phrase check failed\n"
 msgstr ""
 
-#: ../rpm.c:1091
+#: ../rpm.c:1090
 msgid "Pass phrase is good.\n"
 msgstr ""
 
-#: ../rpm.c:1096
+#: ../rpm.c:1095
 msgid "Invalid %%_signature spec in macro file.\n"
 msgstr ""
 
-#: ../rpm.c:1102
+#: ../rpm.c:1101
 msgid "--sign may only be used during package building"
 msgstr ""
 
-#: ../rpm.c:1117
+#: ../rpm.c:1116
 msgid "exec failed\n"
 msgstr ""
 
-#: ../rpm.c:1136
+#: ../rpm.c:1135
 msgid "unexpected arguments to --querytags "
 msgstr ""
 
-#: ../rpm.c:1147
+#: ../rpm.c:1146
 msgid "no packages given for signature check"
 msgstr ""
 
-#: ../rpm.c:1159
+#: ../rpm.c:1158
 msgid "no packages given for signing"
 msgstr ""
 
-#: ../rpm.c:1172
+#: ../rpm.c:1171
 msgid "no packages files given for rebuild"
 msgstr ""
 
-#: ../rpm.c:1229
+#: ../rpm.c:1228
 msgid "no spec files given for build"
 msgstr ""
 
-#: ../rpm.c:1231
+#: ../rpm.c:1230
 msgid "no tar files given for build"
 msgstr ""
 
-#: ../rpm.c:1243
+#: ../rpm.c:1242
 msgid "no packages given for uninstall"
 msgstr ""
 
-#: ../rpm.c:1292
+#: ../rpm.c:1291
 msgid "no packages given for install"
 msgstr ""
 
-#: ../rpm.c:1315
+#: ../rpm.c:1314
 msgid "extra arguments given for query of all packages"
 msgstr ""
 
-#: ../rpm.c:1320
+#: ../rpm.c:1319
 msgid "no arguments given for query"
 msgstr ""
 
-#: ../rpm.c:1337
+#: ../rpm.c:1336
 msgid "extra arguments given for verify of all packages"
 msgstr ""
 
-#: ../rpm.c:1341
+#: ../rpm.c:1340
 msgid "no arguments given for verify"
 msgstr ""
 
@@ -1972,38 +1972,38 @@ msgstr ""
 msgid "error removing record %s into %s"
 msgstr ""
 
-#: ../lib/depends.c:456
+#: ../lib/depends.c:450
 msgid "dbrecMatchesDepFlags() failed to read header"
 msgstr ""
 
-#: ../lib/depends.c:731
+#: ../lib/depends.c:721
 #, c-format
 msgid "dependencies: looking for %s\n"
 msgstr ""
 
 #. requirements are not satisfied.
-#: ../lib/depends.c:870
+#: ../lib/depends.c:860
 #, c-format
 msgid "package %s require not satisfied: %s\n"
 msgstr ""
 
 #. conflicts exist.
-#: ../lib/depends.c:932
+#: ../lib/depends.c:922
 #, c-format
 msgid "package %s conflicts: %s\n"
 msgstr ""
 
-#: ../lib/depends.c:987 ../lib/depends.c:1294
+#: ../lib/depends.c:977 ../lib/depends.c:1282
 #, c-format
 msgid "cannot read header at %d for dependency check"
 msgstr ""
 
-#: ../lib/depends.c:1082
+#: ../lib/depends.c:1072
 #, c-format
 msgid "loop in prerequisite chain: %s"
 msgstr ""
 
-#: ../lib/falloc.c:159
+#: ../lib/falloc.c:160
 #, c-format
 msgid ""
 "free list corrupt (%u)- please run\n"
@@ -2014,8 +2014,8 @@ msgid ""
 msgstr ""
 
 #: ../lib/formats.c:66 ../lib/formats.c:84 ../lib/formats.c:105
-#: ../lib/formats.c:138 ../lib/header.c:2113 ../lib/header.c:2130
-#: ../lib/header.c:2150
+#: ../lib/formats.c:138 ../lib/header.c:2118 ../lib/header.c:2135
+#: ../lib/header.c:2155
 msgid "(not a number)"
 msgstr ""
 
@@ -2024,7 +2024,7 @@ msgstr ""
 msgid "mntctl() failed to return fugger size: %s"
 msgstr ""
 
-#: ../lib/fs.c:75 ../lib/fs.c:254
+#: ../lib/fs.c:75 ../lib/fs.c:253
 #, c-format
 msgid "failed to stat %s: %s"
 msgstr ""
@@ -2038,7 +2038,7 @@ msgstr ""
 msgid "failed to open %s: %s"
 msgstr ""
 
-#: ../lib/fs.c:275
+#: ../lib/fs.c:274
 #, c-format
 msgid "file %s is on an unknown device"
 msgstr ""
@@ -2110,69 +2110,69 @@ msgstr ""
 msgid "Data type %d not supprted\n"
 msgstr ""
 
-#: ../lib/header.c:1110
+#: ../lib/header.c:1115
 #, c-format
 msgid "Bad count for headerAddEntry(): %d\n"
 msgstr ""
 
-#: ../lib/header.c:1511
+#: ../lib/header.c:1516
 #, c-format
 msgid "missing { after %"
 msgstr ""
 
-#: ../lib/header.c:1539
+#: ../lib/header.c:1544
 msgid "missing } after %{"
 msgstr ""
 
-#: ../lib/header.c:1551
+#: ../lib/header.c:1556
 msgid "empty tag format"
 msgstr ""
 
-#: ../lib/header.c:1561
+#: ../lib/header.c:1566
 msgid "empty tag name"
 msgstr ""
 
-#: ../lib/header.c:1576
+#: ../lib/header.c:1581
 msgid "unknown tag"
 msgstr ""
 
-#: ../lib/header.c:1602
+#: ../lib/header.c:1607
 msgid "] expected at end of array"
 msgstr ""
 
-#: ../lib/header.c:1618
+#: ../lib/header.c:1623
 msgid "unexpected ]"
 msgstr ""
 
-#: ../lib/header.c:1620
+#: ../lib/header.c:1625
 msgid "unexpected }"
 msgstr ""
 
-#: ../lib/header.c:1673
+#: ../lib/header.c:1678
 msgid "? expected in expression"
 msgstr ""
 
-#: ../lib/header.c:1680
+#: ../lib/header.c:1685
 msgid "{ expected after ? in expression"
 msgstr ""
 
-#: ../lib/header.c:1690 ../lib/header.c:1722
+#: ../lib/header.c:1695 ../lib/header.c:1727
 msgid "} expected in expression"
 msgstr ""
 
-#: ../lib/header.c:1697
+#: ../lib/header.c:1702
 msgid ": expected following ? subexpression"
 msgstr ""
 
-#: ../lib/header.c:1710
+#: ../lib/header.c:1715
 msgid "{ expected after : in expression"
 msgstr ""
 
-#: ../lib/header.c:1729
+#: ../lib/header.c:1734
 msgid "| expected at end of expression"
 msgstr ""
 
-#: ../lib/header.c:1896
+#: ../lib/header.c:1901
 msgid "(unknown type)"
 msgstr ""
 
@@ -2239,7 +2239,7 @@ msgstr ""
 msgid "renaming %s to %s\n"
 msgstr ""
 
-#: ../lib/install.c:531 ../lib/install.c:807 ../lib/uninstall.c:26
+#: ../lib/install.c:531 ../lib/install.c:809 ../lib/uninstall.c:26
 #, c-format
 msgid "rename of %s to %s failed: %s"
 msgstr ""
@@ -2248,30 +2248,30 @@ msgstr ""
 msgid "source package expected, binary found"
 msgstr ""
 
-#: ../lib/install.c:676
+#: ../lib/install.c:678
 #, c-format
 msgid "package: %s-%s-%s files test = %d\n"
 msgstr ""
 
-#: ../lib/install.c:737
+#: ../lib/install.c:739
 msgid "stopping install as we're running --test\n"
 msgstr ""
 
-#: ../lib/install.c:742
+#: ../lib/install.c:744
 msgid "running preinstall script (if any)\n"
 msgstr ""
 
-#: ../lib/install.c:767
+#: ../lib/install.c:769
 #, c-format
 msgid "warning: %s created as %s"
 msgstr ""
 
-#: ../lib/install.c:803
+#: ../lib/install.c:805
 #, c-format
 msgid "warning: %s saved as %s"
 msgstr ""
 
-#: ../lib/install.c:877
+#: ../lib/install.c:879
 msgid "running postinstall scripts (if any)\n"
 msgstr ""
 
@@ -2280,83 +2280,83 @@ msgstr ""
 msgid "cannot read header at %d for lookup"
 msgstr ""
 
-#: ../lib/macro.c:148
+#: ../lib/macro.c:149
 #, c-format
 msgid "======================== active %d empty %d\n"
 msgstr ""
 
 #. XXX just in case
-#: ../lib/macro.c:242
+#: ../lib/macro.c:243
 #, c-format
 msgid "%3d>%*s(empty)"
 msgstr ""
 
-#: ../lib/macro.c:277
+#: ../lib/macro.c:278
 #, c-format
 msgid "%3d<%*s(empty)\n"
 msgstr ""
 
-#: ../lib/macro.c:456
+#: ../lib/macro.c:457
 msgid "Macro %%%s has unterminated body"
 msgstr ""
 
-#: ../lib/macro.c:482
+#: ../lib/macro.c:483
 msgid "Macro %%%s has illegal name (%%define)"
 msgstr ""
 
-#: ../lib/macro.c:488
+#: ../lib/macro.c:489
 msgid "Macro %%%s has unterminated opts"
 msgstr ""
 
-#: ../lib/macro.c:493
+#: ../lib/macro.c:494
 msgid "Macro %%%s has empty body"
 msgstr ""
 
-#: ../lib/macro.c:498
+#: ../lib/macro.c:499
 msgid "Macro %%%s failed to expand"
 msgstr ""
 
-#: ../lib/macro.c:523
+#: ../lib/macro.c:524
 msgid "Macro %%%s has illegal name (%%undefine)"
 msgstr ""
 
-#: ../lib/macro.c:600
+#: ../lib/macro.c:601
 msgid "Macro %%%s (%s) was not used below level %d"
 msgstr ""
 
-#: ../lib/macro.c:697
+#: ../lib/macro.c:698
 #, c-format
 msgid "Unknown option %c in %s(%s)"
 msgstr ""
 
-#: ../lib/macro.c:869
+#: ../lib/macro.c:870
 #, c-format
 msgid "Recursion depth(%d) greater than max(%d)"
 msgstr ""
 
-#: ../lib/macro.c:935 ../lib/macro.c:951
+#: ../lib/macro.c:936 ../lib/macro.c:952
 #, c-format
 msgid "Unterminated %c: %s"
 msgstr ""
 
-#: ../lib/macro.c:991
+#: ../lib/macro.c:992
 msgid "A %% is followed by an unparseable macro"
 msgstr ""
 
-#: ../lib/macro.c:1114
+#: ../lib/macro.c:1115
 msgid "Macro %%%.*s not found, skipping"
 msgstr ""
 
-#: ../lib/macro.c:1195
+#: ../lib/macro.c:1196
 msgid "Target buffer overflow"
 msgstr ""
 
-#: ../lib/macro.c:1342 ../lib/macro.c:1350
+#: ../lib/macro.c:1343 ../lib/macro.c:1351
 #, c-format
 msgid "File %s: %s"
 msgstr ""
 
-#: ../lib/macro.c:1353
+#: ../lib/macro.c:1354
 #, c-format
 msgid "File %s is smaller than %d bytes"
 msgstr ""
@@ -2387,24 +2387,24 @@ msgstr ""
 msgid "bad file state: %s"
 msgstr ""
 
-#: ../lib/package.c:235
+#: ../lib/package.c:234
 msgid "package is a version one package!\n"
 msgstr ""
 
-#: ../lib/package.c:240
+#: ../lib/package.c:239
 msgid "old style source package -- I'll do my best\n"
 msgstr ""
 
-#: ../lib/package.c:243
+#: ../lib/package.c:242
 #, c-format
 msgid "archive offset is %d\n"
 msgstr ""
 
-#: ../lib/package.c:253
+#: ../lib/package.c:252
 msgid "old style binary package\n"
 msgstr ""
 
-#: ../lib/package.c:297
+#: ../lib/package.c:298
 msgid ""
 "only packages with major numbers <= 3 are supported by this version of RPM"
 msgstr ""
@@ -2465,257 +2465,257 @@ msgstr ""
 msgid "unknown error %d encountered while manipulating package %s-%s-%s"
 msgstr ""
 
-#: ../lib/query.c:139
+#: ../lib/query.c:138
 #, c-format
 msgid "error in format: %s\n"
 msgstr ""
 
-#: ../lib/query.c:181
+#: ../lib/query.c:180
 msgid "(contains no files)"
 msgstr ""
 
-#: ../lib/query.c:234
+#: ../lib/query.c:233
 msgid "normal        "
 msgstr ""
 
-#: ../lib/query.c:236
+#: ../lib/query.c:235
 msgid "replaced      "
 msgstr ""
 
-#: ../lib/query.c:238
+#: ../lib/query.c:237
 msgid "not installed "
 msgstr ""
 
-#: ../lib/query.c:240
+#: ../lib/query.c:239
 msgid "net shared    "
 msgstr ""
 
-#: ../lib/query.c:242
+#: ../lib/query.c:241
 #, c-format
 msgid "(unknown %3d) "
 msgstr ""
 
-#: ../lib/query.c:246
+#: ../lib/query.c:245
 msgid "(no state)    "
 msgstr ""
 
-#: ../lib/query.c:262 ../lib/query.c:292
+#: ../lib/query.c:261 ../lib/query.c:291
 msgid "package has neither file owner or id lists"
 msgstr ""
 
-#: ../lib/query.c:401
+#: ../lib/query.c:400
 #, c-format
 msgid "record number %u\n"
 msgstr ""
 
-#: ../lib/query.c:405
+#: ../lib/query.c:404
 msgid "error: could not read database record\n"
 msgstr ""
 
-#: ../lib/query.c:443
+#: ../lib/query.c:442
 #, c-format
 msgid "open of %s failed: %s\n"
 msgstr ""
 
-#: ../lib/query.c:456
+#: ../lib/query.c:455
 msgid "old format source packages cannot be queried\n"
 msgstr ""
 
-#: ../lib/query.c:465 ../lib/rpminstall.c:203
+#: ../lib/query.c:464 ../lib/rpminstall.c:203
 #, c-format
 msgid "%s does not appear to be a RPM package\n"
 msgstr ""
 
-#: ../lib/query.c:468
+#: ../lib/query.c:467
 #, c-format
 msgid "query of %s failed\n"
 msgstr ""
 
-#: ../lib/query.c:495
+#: ../lib/query.c:494
 #, c-format
 msgid "query of specfile %s failed, can't parse\n"
 msgstr ""
 
-#: ../lib/query.c:520
+#: ../lib/query.c:519
 msgid "could not read database record!\n"
 msgstr ""
 
-#: ../lib/query.c:531
+#: ../lib/query.c:530
 #, c-format
 msgid "group %s does not contain any packages\n"
 msgstr ""
 
-#: ../lib/query.c:541
+#: ../lib/query.c:540
 #, c-format
 msgid "no package provides %s\n"
 msgstr ""
 
-#: ../lib/query.c:551
+#: ../lib/query.c:550
 #, c-format
 msgid "no package triggers %s\n"
 msgstr ""
 
-#: ../lib/query.c:561
+#: ../lib/query.c:560
 #, c-format
 msgid "no package requires %s\n"
 msgstr ""
 
-#: ../lib/query.c:576
+#: ../lib/query.c:575
 #, c-format
 msgid "file %s: %s\n"
 msgstr ""
 
-#: ../lib/query.c:579
+#: ../lib/query.c:578
 #, c-format
 msgid "file %s is not owned by any package\n"
 msgstr ""
 
-#: ../lib/query.c:592
+#: ../lib/query.c:591
 #, c-format
 msgid "invalid package number: %s\n"
 msgstr ""
 
-#: ../lib/query.c:595
+#: ../lib/query.c:594
 #, c-format
 msgid "package record number: %d\n"
 msgstr ""
 
-#: ../lib/query.c:598
+#: ../lib/query.c:597
 #, c-format
 msgid "record %d could not be read\n"
 msgstr ""
 
-#: ../lib/query.c:610 ../lib/rpminstall.c:385
+#: ../lib/query.c:609 ../lib/rpminstall.c:393
 #, c-format
 msgid "package %s is not installed\n"
 msgstr ""
 
-#: ../lib/query.c:613
+#: ../lib/query.c:612
 #, c-format
 msgid "error looking for package %s\n"
 msgstr ""
 
-#: ../lib/query.c:635
+#: ../lib/query.c:634
 msgid "rpmQuery: rpmdbOpen() failed\n"
 msgstr ""
 
-#: ../lib/query.c:692
+#: ../lib/query.c:691
 msgid "query package owning file"
 msgstr ""
 
-#: ../lib/query.c:694
+#: ../lib/query.c:693
 msgid "query packages in group"
 msgstr ""
 
-#: ../lib/query.c:696
+#: ../lib/query.c:695
 msgid "query a package file"
 msgstr ""
 
-#: ../lib/query.c:700
+#: ../lib/query.c:699
 msgid "query a spec file"
 msgstr ""
 
-#: ../lib/query.c:702
+#: ../lib/query.c:701
 msgid "query the pacakges triggered by the package"
 msgstr ""
 
-#: ../lib/query.c:704
+#: ../lib/query.c:703
 msgid "query the packages which require a capability"
 msgstr ""
 
-#: ../lib/query.c:706
+#: ../lib/query.c:705
 msgid "query the packages which provide a capability"
 msgstr ""
 
-#: ../lib/query.c:743
+#: ../lib/query.c:742
 msgid "list all configuration files"
 msgstr ""
 
-#: ../lib/query.c:745
+#: ../lib/query.c:744
 msgid "list all documentation files"
 msgstr ""
 
-#: ../lib/query.c:747
+#: ../lib/query.c:746
 msgid "dump basic file information"
 msgstr ""
 
-#: ../lib/query.c:749
+#: ../lib/query.c:748
 msgid "list files in package"
 msgstr ""
 
-#: ../lib/query.c:753
+#: ../lib/query.c:752
 msgid "use the following query format"
 msgstr ""
 
-#: ../lib/query.c:755
+#: ../lib/query.c:754
 msgid "substitute i18n sections from the following catalogue"
 msgstr ""
 
-#: ../lib/query.c:758
+#: ../lib/query.c:757
 msgid "display the states of the listed files"
 msgstr ""
 
-#: ../lib/query.c:760
+#: ../lib/query.c:759
 msgid "display a verbose file listing"
 msgstr ""
 
-#: ../lib/rebuilddb.c:19
+#: ../lib/rebuilddb.c:20
 #, c-format
 msgid "rebuilding database in rootdir %s\n"
 msgstr ""
 
-#: ../lib/rebuilddb.c:23 ../lib/rpmdb.c:69 ../lib/rpmdb.c:88
+#: ../lib/rebuilddb.c:24 ../lib/rpmdb.c:69 ../lib/rpmdb.c:88
 #: ../lib/rpmdb.c:105
 msgid "no dbpath has been set"
 msgstr ""
 
-#: ../lib/rebuilddb.c:32
+#: ../lib/rebuilddb.c:33
 #, c-format
 msgid "temporary database %s already exists"
 msgstr ""
 
-#: ../lib/rebuilddb.c:36
+#: ../lib/rebuilddb.c:37
 #, c-format
 msgid "creating directory: %s\n"
 msgstr ""
 
-#: ../lib/rebuilddb.c:38
+#: ../lib/rebuilddb.c:39
 #, c-format
 msgid "error creating directory %s: %s"
 msgstr ""
 
-#: ../lib/rebuilddb.c:42
+#: ../lib/rebuilddb.c:43
 msgid "opening old database\n"
 msgstr ""
 
-#: ../lib/rebuilddb.c:49
+#: ../lib/rebuilddb.c:50
 msgid "opening new database\n"
 msgstr ""
 
-#: ../lib/rebuilddb.c:59 ../lib/rebuilddb.c:77
+#: ../lib/rebuilddb.c:60 ../lib/rebuilddb.c:78
 #, c-format
 msgid "record number %d in database is bad -- skipping it"
 msgstr ""
 
-#: ../lib/rebuilddb.c:71
+#: ../lib/rebuilddb.c:72
 #, c-format
 msgid "cannot add record originally at %d"
 msgstr ""
 
-#: ../lib/rebuilddb.c:90
+#: ../lib/rebuilddb.c:91
 msgid "failed to rebuild database; original database remains in place\n"
 msgstr ""
 
-#: ../lib/rebuilddb.c:98
+#: ../lib/rebuilddb.c:99
 msgid "failed to replace old database with new database!\n"
 msgstr ""
 
-#: ../lib/rebuilddb.c:100
+#: ../lib/rebuilddb.c:101
 #, c-format
 msgid "replaces files in %s with files from %s to recover"
 msgstr ""
 
-#: ../lib/rebuilddb.c:106
+#: ../lib/rebuilddb.c:107
 #, c-format
 msgid "failed to remove directory %s: %s\n"
 msgstr ""
@@ -2939,12 +2939,12 @@ msgstr ""
 msgid "retrieved %d packages\n"
 msgstr ""
 
-#: ../lib/rpminstall.c:191 ../lib/rpminstall.c:324
+#: ../lib/rpminstall.c:191 ../lib/rpminstall.c:332
 #, c-format
 msgid "cannot open file %s\n"
 msgstr ""
 
-#: ../lib/rpminstall.c:207 ../lib/rpminstall.c:461
+#: ../lib/rpminstall.c:207 ../lib/rpminstall.c:469
 #, c-format
 msgid "%s cannot be installed\n"
 msgstr ""
@@ -2954,49 +2954,49 @@ msgstr ""
 msgid "package %s is not relocateable\n"
 msgstr ""
 
-#: ../lib/rpminstall.c:255
+#: ../lib/rpminstall.c:261
 #, c-format
 msgid "error reading from file %s\n"
 msgstr ""
 
-#: ../lib/rpminstall.c:258
+#: ../lib/rpminstall.c:266
 #, c-format
 msgid "file %s requires a newer version of RPM\n"
 msgstr ""
 
-#: ../lib/rpminstall.c:275
+#: ../lib/rpminstall.c:283
 #, c-format
 msgid "found %d source and %d binary packages\n"
 msgstr ""
 
-#: ../lib/rpminstall.c:286
+#: ../lib/rpminstall.c:294
 msgid "failed dependencies:\n"
 msgstr ""
 
-#: ../lib/rpminstall.c:304
+#: ../lib/rpminstall.c:312
 msgid "installing binary packages\n"
 msgstr ""
 
-#: ../lib/rpminstall.c:389
+#: ../lib/rpminstall.c:397
 #, c-format
 msgid "searching for package %s\n"
 msgstr ""
 
-#: ../lib/rpminstall.c:398
+#: ../lib/rpminstall.c:406
 #, c-format
 msgid "\"%s\" specifies multiple packages\n"
 msgstr ""
 
-#: ../lib/rpminstall.c:424
+#: ../lib/rpminstall.c:432
 msgid "removing these packages would break dependencies:\n"
 msgstr ""
 
-#: ../lib/rpminstall.c:451
+#: ../lib/rpminstall.c:459
 #, c-format
 msgid "cannot open %s\n"
 msgstr ""
 
-#: ../lib/rpminstall.c:456
+#: ../lib/rpminstall.c:464
 #, c-format
 msgid "Installing %s\n"
 msgstr ""
@@ -3006,92 +3006,92 @@ msgstr ""
 msgid "read failed: %s (%d)"
 msgstr ""
 
-#: ../lib/rpmrc.c:178
+#: ../lib/rpmrc.c:177
 #, c-format
 msgid "missing second ':' at %s:%d"
 msgstr ""
 
-#: ../lib/rpmrc.c:181
+#: ../lib/rpmrc.c:180
 #, c-format
 msgid "missing architecture name at %s:%d"
 msgstr ""
 
-#: ../lib/rpmrc.c:329
+#: ../lib/rpmrc.c:328
 #, c-format
 msgid "Incomplete data line at %s:%d"
 msgstr ""
 
-#: ../lib/rpmrc.c:333
+#: ../lib/rpmrc.c:332
 #, c-format
 msgid "Too many args in data line at %s:%d"
 msgstr ""
 
-#: ../lib/rpmrc.c:340
+#: ../lib/rpmrc.c:339
 #, c-format
 msgid "Bad arch/os number: %s (%s:%d)"
 msgstr ""
 
-#: ../lib/rpmrc.c:374
+#: ../lib/rpmrc.c:373
 #, c-format
 msgid "Incomplete default line at %s:%d"
 msgstr ""
 
-#: ../lib/rpmrc.c:379
+#: ../lib/rpmrc.c:378
 #, c-format
 msgid "Too many args in default line at %s:%d"
 msgstr ""
 
-#: ../lib/rpmrc.c:562
+#: ../lib/rpmrc.c:561
 #, c-format
 msgid "Cannot expand %s"
 msgstr ""
 
-#: ../lib/rpmrc.c:577
+#: ../lib/rpmrc.c:576
 #, c-format
 msgid "Unable to open %s for reading: %s."
 msgstr ""
 
-#: ../lib/rpmrc.c:609
+#: ../lib/rpmrc.c:608
 #, c-format
 msgid "Failed to read %s: %s."
 msgstr ""
 
-#: ../lib/rpmrc.c:639
+#: ../lib/rpmrc.c:638
 #, c-format
 msgid "missing ':' at %s:%d"
 msgstr ""
 
-#: ../lib/rpmrc.c:656 ../lib/rpmrc.c:730
+#: ../lib/rpmrc.c:655 ../lib/rpmrc.c:729
 #, c-format
 msgid "missing argument for %s at %s:%d"
 msgstr ""
 
-#: ../lib/rpmrc.c:673 ../lib/rpmrc.c:695
+#: ../lib/rpmrc.c:672 ../lib/rpmrc.c:694
 #, c-format
 msgid "%s expansion failed at %s:%d \"%s\""
 msgstr ""
 
-#: ../lib/rpmrc.c:681
+#: ../lib/rpmrc.c:680
 #, c-format
 msgid "cannot open %s at %s:%d"
 msgstr ""
 
-#: ../lib/rpmrc.c:722
+#: ../lib/rpmrc.c:721
 #, c-format
 msgid "missing architecture for %s at %s:%d"
 msgstr ""
 
-#: ../lib/rpmrc.c:789
+#: ../lib/rpmrc.c:788
 #, c-format
 msgid "bad option '%s' at %s:%d"
 msgstr ""
 
-#: ../lib/rpmrc.c:1148
+#: ../lib/rpmrc.c:1147
 #, c-format
 msgid "Unknown system: %s\n"
 msgstr ""
 
-#: ../lib/rpmrc.c:1149
+#: ../lib/rpmrc.c:1148
 msgid "Please contact rpm-list@redhat.com\n"
 msgstr ""
 
@@ -3141,108 +3141,108 @@ msgstr ""
 msgid "Signature pad : %d\n"
 msgstr ""
 
-#: ../lib/signature.c:265
+#: ../lib/signature.c:266
 #, c-format
 msgid "Couldn't exec pgp (%s)"
 msgstr ""
 
-#: ../lib/signature.c:276
+#: ../lib/signature.c:277
 msgid "pgp failed"
 msgstr ""
 
 #. PGP failed to write signature
 #. Just in case
-#: ../lib/signature.c:283
+#: ../lib/signature.c:284
 msgid "pgp failed to write signature"
 msgstr ""
 
-#: ../lib/signature.c:288
+#: ../lib/signature.c:289
 #, c-format
 msgid "PGP sig size: %d\n"
 msgstr ""
 
-#: ../lib/signature.c:299 ../lib/signature.c:376
+#: ../lib/signature.c:300 ../lib/signature.c:377
 msgid "unable to read the signature"
 msgstr ""
 
-#: ../lib/signature.c:304
+#: ../lib/signature.c:305
 #, c-format
 msgid "Got %d bytes of PGP sig\n"
 msgstr ""
 
-#: ../lib/signature.c:342 ../lib/signature.c:685
+#: ../lib/signature.c:343 ../lib/signature.c:686
 msgid "Couldn't exec gpg"
 msgstr ""
 
-#: ../lib/signature.c:353
+#: ../lib/signature.c:354
 msgid "gpg failed"
 msgstr ""
 
 #. GPG failed to write signature
 #. Just in case
-#: ../lib/signature.c:360
+#: ../lib/signature.c:361
 msgid "gpg failed to write signature"
 msgstr ""
 
-#: ../lib/signature.c:365
+#: ../lib/signature.c:366
 #, c-format
 msgid "GPG sig size: %d\n"
 msgstr ""
 
-#: ../lib/signature.c:381
+#: ../lib/signature.c:382
 #, c-format
 msgid "Got %d bytes of GPG sig\n"
 msgstr ""
 
-#: ../lib/signature.c:408
+#: ../lib/signature.c:409
 msgid "Generating signature using PGP.\n"
 msgstr ""
 
-#: ../lib/signature.c:414
+#: ../lib/signature.c:415
 msgid "Generating signature using GPG.\n"
 msgstr ""
 
-#: ../lib/signature.c:491 ../lib/signature.c:553
+#: ../lib/signature.c:492 ../lib/signature.c:554
 msgid "Could not run pgp.  Use --nopgp to skip PGP checks."
 msgstr ""
 
-#: ../lib/signature.c:551 ../lib/signature.c:624
+#: ../lib/signature.c:552 ../lib/signature.c:625
 msgid "exec failed!\n"
 msgstr ""
 
-#: ../lib/signature.c:626
+#: ../lib/signature.c:627
 msgid "Could not run gpg.  Use --nogpg to skip GPG checks."
 msgstr ""
 
-#: ../lib/signature.c:714
+#: ../lib/signature.c:715
 msgid "Couldn't exec pgp"
 msgstr ""
 
 #. @notreached@
 #. This case should have been screened out long ago.
-#: ../lib/signature.c:718 ../lib/signature.c:771
+#: ../lib/signature.c:719 ../lib/signature.c:772
 msgid "Invalid %%_signature spec in macro file"
 msgstr ""
 
-#: ../lib/signature.c:751
+#: ../lib/signature.c:752
 msgid "You must set \"%%_gpg_name\" in your macro file"
 msgstr ""
 
-#: ../lib/signature.c:763
+#: ../lib/signature.c:764
 msgid "You must set \"%%_pgp_name\" in your macro file"
 msgstr ""
 
-#: ../lib/transaction.c:358
+#: ../lib/transaction.c:363
 #, c-format
 msgid "relocating %s to %s\n"
 msgstr ""
 
-#: ../lib/transaction.c:365
+#: ../lib/transaction.c:370
 #, c-format
 msgid "excluding %s\n"
 msgstr ""
 
-#: ../lib/transaction.c:481
+#: ../lib/transaction.c:486
 #, c-format
 msgid "%s skipped due to missingok flag\n"
 msgstr ""
@@ -3280,7 +3280,7 @@ msgstr ""
 msgid "removing database entry\n"
 msgstr ""
 
-#: ../lib/uninstall.c:363
+#: ../lib/uninstall.c:365
 msgid "execution of script failed"
 msgstr ""
 
diff --git a/rpm.c b/rpm.c
index 44ed042..c84f4d4 100755 (executable)
--- a/rpm.c
+++ b/rpm.c
@@ -1,11 +1,10 @@
 #include "system.h"
 
-#include "build/rpmbuild.h"
+#include "rpmbuild.h"
 
 #include "build.h"
 #include "install.h"
-#include "lib/signature.h"
-#include "popt/popt.h"
+#include "signature.h"
 
 #define GETOPT_REBUILD         1003
 #define GETOPT_RECOMPILE       1004
@@ -824,7 +823,7 @@ int main(int argc, char ** argv)
            *errString++ = '\0';
            if (*errString != '/') 
                argerror(_("relocations must have a / following the ="));
-           relocations = realloc(relocations, 
+           relocations = xrealloc(relocations, 
                                  sizeof(*relocations) * (numRelocations + 1));
            relocations[numRelocations].oldPath = optArg;
            relocations[numRelocations++].newPath = errString;
@@ -834,7 +833,7 @@ int main(int argc, char ** argv)
            if (*optArg != '/') 
                argerror(_("exclude paths must begin with a /"));
 
-           relocations = realloc(relocations, 
+           relocations = xrealloc(relocations, 
                                  sizeof(*relocations) * (numRelocations + 1));
            relocations[numRelocations].oldPath = optArg;
            relocations[numRelocations++].newPath = NULL;
@@ -1089,7 +1088,7 @@ int main(int argc, char ** argv)
                        exit(EXIT_FAILURE);
                    }
                    fprintf(stderr, _("Pass phrase is good.\n"));
-                   passPhrase = strdup(passPhrase);
+                   passPhrase = xstrdup(passPhrase);
                    break;
                  default:
                    fprintf(stderr,
@@ -1298,7 +1297,7 @@ int main(int argc, char ** argv)
            relocations[0].newPath = prefix;
            relocations[1].oldPath = relocations[1].newPath = NULL;
        } else if (relocations) {
-           relocations = realloc(relocations, 
+           relocations = xrealloc(relocations, 
                                  sizeof(*relocations) * (numRelocations + 1));
            relocations[numRelocations].oldPath = NULL;
            relocations[numRelocations].newPath = NULL;
@@ -1346,6 +1345,8 @@ int main(int argc, char ** argv)
     }
 
     poptFreeContext(optCon);
+    freeMacros(NULL);
+    rpmFreeRpmrc();
 
     if (pipeChild) {
        fclose(stdout);
index de510a4..156e40d 100644 (file)
--- 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.28
+Release: 0.29
 Group: System Environment/Base
 Source: ftp://ftp.rpm.org/pub/rpm/dist/rpm-3.0.x/rpm-%{version}.tar.gz
 Copyright: GPL
index 46cccb4..3131489 100644 (file)
@@ -88,12 +88,13 @@ expandMacroTable(MacroContext *mc)
 {
        if (mc->macroTable == NULL) {
                mc->macrosAllocated = MACRO_CHUNK_SIZE;
-               mc->macroTable = (MacroEntry **)malloc(sizeof(*(mc->macroTable)) *
-                               mc->macrosAllocated);
+               mc->macroTable = (MacroEntry **)
+                   xmalloc(sizeof(*(mc->macroTable)) * mc->macrosAllocated);
                mc->firstFree = 0;
        } else {
                mc->macrosAllocated += MACRO_CHUNK_SIZE;
-               mc->macroTable = (MacroEntry **)realloc(mc->macroTable, sizeof(*(mc->macroTable)) *
+               mc->macroTable = (MacroEntry **)
+                   xrealloc(mc->macroTable, sizeof(*(mc->macroTable)) *
                                mc->macrosAllocated);
        }
        memset(&mc->macroTable[mc->firstFree], 0, MACRO_CHUNK_SIZE * sizeof(*(mc->macroTable)));
@@ -547,12 +548,12 @@ static void
 pushMacro(MacroEntry **mep, const char *n, const char *o, const char *b, int level)
 {
        MacroEntry *prev = (*mep ? *mep : NULL);
-       MacroEntry *me = (MacroEntry *) malloc(sizeof(*me));
+       MacroEntry *me = (MacroEntry *) xmalloc(sizeof(*me));
 
        me->prev = prev;
-       me->name = (prev ? prev->name : strdup(n));
-       me->opts = (o ? strdup(o) : NULL);
-       me->body = strdup(b ? b : "");
+       me->name = (prev ? prev->name : xstrdup(n));
+       me->opts = (o ? xstrdup(o) : NULL);
+       me->body = xstrdup(b ? b : "");
        me->used = 0;
        me->level = level;
        *mep = me;
@@ -1260,7 +1261,7 @@ initMacros(MacroContext *mc, const char *macrofiles)
        if (mc == NULL)
                mc = &globalMacroContext;
 
-       for (mfile = m = strdup(macrofiles); *mfile; mfile = me) {
+       for (mfile = m = xstrdup(macrofiles); *mfile; mfile = me) {
                FILE *fp;
                char buf[BUFSIZ];
 
@@ -1381,7 +1382,7 @@ rpmExpand(const char *arg, ...)
     va_list ap;
 
     if (arg == NULL)
-       return strdup("");
+       return xstrdup("");
 
     p = buf;
     strcpy(p, arg);
@@ -1396,7 +1397,7 @@ rpmExpand(const char *arg, ...)
     }
     va_end(ap);
     expandMacros(NULL, NULL, buf, sizeof(buf));
-    return strdup(buf);
+    return xstrdup(buf);       /* XXX build memory leaks */
 }
 
 int
@@ -1435,7 +1436,7 @@ rpmGetPath(const char *path, ...)
     va_list ap;
 
     if (path == NULL)
-       return strdup("");
+       return xstrdup("");
 
     p = buf;
     strcpy(p, path);
@@ -1455,7 +1456,7 @@ rpmGetPath(const char *path, ...)
     }
     va_end(ap);
     expandMacros(NULL, NULL, buf, sizeof(buf));
-    return strdup(buf);
+    return xstrdup(buf);
 }
 
 /* =============================================================== */
index db486cd..7d6f974 100644 (file)
--- a/system.h
+++ b/system.h
@@ -184,14 +184,39 @@ char *alloca ();
 #include <limits.h>
 #endif
 
+#if HAVE_ERR_H
+#include <err.h>
+#endif
+
 #if HAVE_MALLOC_H
 #include <malloc.h>
 #endif
 
+/*@only@*/ void * xmalloc (size_t size);
+/*@only@*/ void * xcalloc (size_t nmemb, size_t size);
+/*@only@*/ void * xrealloc (void *ptr, size_t size);
+/*@only@*/ char * xstrdup (const char *str);
+void *vmefail(void);
+
 #if HAVE_MCHECK_H
 #include <mcheck.h>
 #endif
 
+
+#if HAVE_MCHECK_H && defined(__GNUC__)
+
+/* Memory allocation via macro defs to get meaningful locations from mtrace() */
+
+#define        xmalloc(_size)          (malloc(_size) ? : vmefail())
+
+#define        xcalloc(_nmemb, _size)  (calloc((_nmemb), (_size)) ? : vmefail())
+
+#define        xrealloc(_ptr, _size)   (realloc((_ptr), (_size)) ? : vmefail())
+
+#define        xstrdup(_str)   (strcpy((malloc(strlen(_str)+1) ? : vmefail()), (_str)))
+
+#endif /* HAVE_MCHECK_H && defined(__GNUC__) */
+
 #if HAVE_NETDB_H
 #ifndef __LCLINT__
 #include <netdb.h>
index e8feca9..671792b 100644 (file)
@@ -122,11 +122,11 @@ genSrpmFileName(Header h)
 
 #if 0
     if (strcmp(sourcerpm, sfn))
-       return strdup(sourcerpm);
+       return xstrdup(sourcerpm);
 
     return NULL;
 #else
-    return strdup(sourcerpm);
+    return xstrdup(sourcerpm);
 #endif
 
 }
@@ -153,10 +153,6 @@ hasLang(const char *onlylang, char **langs, char **s)
 /* ================================================================== */
 /* XXX stripped down gettext environment */
 
-#define        xstrdup         strdup
-#define        xmalloc         malloc
-#define        xrealloc        realloc
-
 #if !defined(PARAMS)
 #define        PARAMS(_x)      _x
 #endif