RPM Package Manager, CVS Repository
  http://rpm5.org/cvs/
  ____________________________________________________________________________

  Server: rpm5.org                         Name:   Jeff Johnson
  Root:   /v/rpm/cvs                       Email:  [EMAIL PROTECTED]
  Module: rpm                              Date:   27-Nov-2007 03:29:27
  Branch: HEAD                             Handle: 2007112702292601

  Modified files:
    rpm                     CHANGES
    rpm/build               files.c pack.c parsePrep.c
    rpm/rpmdb               header.c legacy.c

  Log:
    - rpmbuild: plug some memory leaks.
    - fix: return 0, not -1, with unsigned changes as error.

  Summary:
    Revision    Changes     Path
    1.1893      +2  -0      rpm/CHANGES
    1.298       +3  -1      rpm/build/files.c
    2.258       +15 -5      rpm/build/pack.c
    2.95        +6  -3      rpm/build/parsePrep.c
    1.140       +12 -12     rpm/rpmdb/header.c
    1.37        +3  -3      rpm/rpmdb/legacy.c
  ____________________________________________________________________________

  patch -p0 <<'@@ .'
  Index: rpm/CHANGES
  ============================================================================
  $ cvs diff -u -r1.1892 -r1.1893 CHANGES
  --- rpm/CHANGES       26 Nov 2007 06:52:52 -0000      1.1892
  +++ rpm/CHANGES       27 Nov 2007 02:29:26 -0000      1.1893
  @@ -1,4 +1,6 @@
   5.0a2 -> 5.0a3:
  +    - jbj: rpmbuild: plug some memory leaks.
  +    - jbj: fix: return 0, not -1, with unsigned changes as error.
       - jbj: add HEADERGET_NOEXTENSION disabler, kill off headerGetEntry.
       - jbj: 1 down, 2 to go, to get rid of headerGetEntry.
       - jbj: limit headerGetEntry usage to -lrpmdb only.
  @@ .
  patch -p0 <<'@@ .'
  Index: rpm/build/files.c
  ============================================================================
  $ cvs diff -u -r1.297 -r1.298 files.c
  --- rpm/build/files.c 26 Nov 2007 06:15:34 -0000      1.297
  +++ rpm/build/files.c 27 Nov 2007 02:29:27 -0000      1.298
  @@ -1025,8 +1025,10 @@
                const char *ddir, *fmt, *errstr;
                if (!oneshot) {
                    _docdir_fmt = rpmExpand("%{?_docdir_fmt}", NULL);
  -                 if (!_docdir_fmt || !*_docdir_fmt)
  +                 if (!_docdir_fmt || !*_docdir_fmt) {
  +                     _docdir_fmt = _free(_docdir_fmt);
                        _docdir_fmt = "%{NAME}-%{VERSION}";
  +                 }
                    oneshot = 1;
                }
                fmt = headerSprintf(pkg->header, _docdir_fmt, NULL, 
rpmHeaderFormats, &errstr);
  @@ .
  patch -p0 <<'@@ .'
  Index: rpm/build/pack.c
  ============================================================================
  $ cvs diff -u -r2.257 -r2.258 pack.c
  --- rpm/build/pack.c  24 Nov 2007 23:15:31 -0000      2.257
  +++ rpm/build/pack.c  27 Nov 2007 02:29:27 -0000      2.258
  @@ -43,12 +43,16 @@
        /[EMAIL PROTECTED] spec->sourceRpmName @*/
   {
       if (spec->sourceRpmName == NULL) {
  -     const char *name, *version, *release;
  +     const char *N, *V, *R;
        char fileName[BUFSIZ];
   
  -     (void) headerNEVRA(spec->packages->header, &name, NULL, &version, 
&release, NULL);
  -     sprintf(fileName, "%s-%s-%s.%ssrc.rpm", name, version, release,
  +     (void) headerNEVRA(spec->packages->header, &N, NULL, &V, &R, NULL);
  +     snprintf(fileName, sizeof(fileName), "%s-%s-%s.%ssrc.rpm", N, V, R,
            spec->noSource ? "no" : "");
  +     fileName[sizeof(fileName)-1] = '\0';
  +     N = _free(N);
  +     V = _free(V);
  +     R = _free(R);
        spec->sourceRpmName = xstrdup(fileName);
       }
   
  @@ -495,6 +499,8 @@
        p += strlen(p);
       }
       (void) stpcpy( stpcpy( stpcpy(p, V) , "-") , R);
  +    V = _free(V);
  +    R = _free(R);
   
       /*
        * Rpm prior to 3.0.3 does not have versioned provides.
  @@ -584,6 +590,7 @@
        xx = headerPut(h, he, 0);
        he->append = 0;
       }
  +    N = _free(N);
   }
   
   /[EMAIL PROTECTED]@*/
  @@ -687,8 +694,8 @@
   
       /* Create and add the cookie */
       if (cookie) {
  -     sprintf(buf, "%s %d", buildHost(), (int) (*getBuildTime()));
  -     *cookie = xstrdup(buf);
  +     sprintf(buf, "%s %u", buildHost(), (unsigned) (*getBuildTime()));
  +     *cookie = xstrdup(buf);         /* XXX memory leak */
        he->tag = RPMTAG_COOKIE;
        he->t = RPM_STRING_TYPE;
        he->p.str = *cookie;
  @@ -813,6 +820,9 @@
            (void) headerNEVRA(h, &N, NULL, &V, &R, NULL);
            sprintf(buf, "%s-%s-%s", N, V, R);
            rc = rpmpkgWrite(item, fd, l, &msg);
  +         N = _free(N);
  +         V = _free(V);
  +         R = _free(R);
        }
   
        if (rc != RPMRC_OK) {
  @@ .
  patch -p0 <<'@@ .'
  Index: rpm/build/parsePrep.c
  ============================================================================
  $ cvs diff -u -r2.94 -r2.95 parsePrep.c
  --- rpm/build/parsePrep.c     26 Nov 2007 05:16:49 -0000      2.94
  +++ rpm/build/parsePrep.c     27 Nov 2007 02:29:27 -0000      2.95
  @@ -383,9 +383,12 @@
       if (dirName) {
        spec->buildSubdir = xstrdup(dirName);
       } else {
  -     const char *name, *version;
  -     (void) headerNEVRA(spec->packages->header, &name, NULL, &version, NULL, 
NULL);
  -     sprintf(buf, "%s-%s", name, version);
  +     const char *N, *V;
  +     (void) headerNEVRA(spec->packages->header, &N, NULL, &V, NULL, NULL);
  +     snprintf(buf, sizeof(buf), "%s-%s", N, V);
  +     buf[sizeof(buf)-1] = '\0';
  +     N = _free(N);
  +     V = _free(V);
        spec->buildSubdir = xstrdup(buf);
       }
       addMacro(spec->macros, "buildsubdir", NULL, spec->buildSubdir, 
RMIL_SPEC);
  @@ .
  patch -p0 <<'@@ .'
  Index: rpm/rpmdb/header.c
  ============================================================================
  $ cvs diff -u -r1.139 -r1.140 header.c
  --- rpm/rpmdb/header.c        26 Nov 2007 21:05:57 -0000      1.139
  +++ rpm/rpmdb/header.c        27 Nov 2007 02:29:27 -0000      1.140
  @@ -334,7 +334,7 @@
       switch (type) {
       case RPM_STRING_TYPE:
        if (count != 1)
  -         return -1;
  +         return 0;
        while (*s++ != '\0') {
            if (se && s > se)
                return 0;
  @@ -349,7 +349,7 @@
        if (onDisk) {
            while (count--) {
                length++;       /* count nul terminator too */
  -               while (*s++ != '\0') {
  +             while (*s++ != '\0') {
                    if (se && s > se)
                        return 0;
                    length++;
  @@ -429,17 +429,17 @@
   assert(ie.info.offset >= 0); /* XXX insurance */
   
        if (hdrchkType(ie.info.type))
  -         return -1;
  +         return 0;
        if (hdrchkData(ie.info.count))
  -         return -1;
  +         return 0;
        if (hdrchkData(ie.info.offset))
  -         return -1;
  +         return 0;
        if (hdrchkAlign(ie.info.type, ie.info.offset))
  -         return -1;
  +         return 0;
   
        ie.data = t = dataStart + ie.info.offset;
        if (dataEnd && t >= dataEnd)
  -         return -1;
  +         return 0;
   
        p.ptr = ie.data;
        pend.ui8p = (uint8_t *) dataEnd;
  @@ -447,7 +447,7 @@
        ie.length = dataLength(ie.info.type, &p, ie.info.count, 1, &pend);
   /[EMAIL PROTECTED]@*/
        if (ie.length == 0 || hdrchkData(ie.length))
  -         return -1;
  +         return 0;
   
        ie.rdlen = 0;
   
  @@ -491,7 +491,7 @@
            uint32_t b[2];
            for (; ie.info.count > 0; ie.info.count--, it += 1) {
                if (dataEnd && ((unsigned char *)it) >= dataEnd)
  -                 return -1;
  +                 return 0;
                b[1] = (uint32_t) htonl(((uint32_t *)it)[0]);
                b[0] = (uint32_t) htonl(((uint32_t *)it)[1]);
                if (b[1] != ((uint32_t *)it)[0])
  @@ -503,7 +503,7 @@
        {   uint32_t * it = (uint32_t *)t;
            for (; ie.info.count > 0; ie.info.count--, it += 1) {
                if (dataEnd && ((unsigned char *)it) >= dataEnd)
  -                 return -1;
  +                 return 0;
                *it = (uint32_t) htonl(*it);
            }
            t = (unsigned char *) it;
  @@ -512,7 +512,7 @@
        {   uint16_t * it = (uint16_t *) t;
            for (; ie.info.count > 0; ie.info.count--, it += 1) {
                if (dataEnd && ((unsigned char *)it) >= dataEnd)
  -                 return -1;
  +                 return 0;
                *it = (uint16_t) htons(*it);
            }
            t = (unsigned char *) it;
  @@ -523,7 +523,7 @@
        }
   
        dl += ie.length;
  -     if (dataEnd && (dataStart + dl) > dataEnd) return -1;
  +     if (dataEnd && (dataStart + dl) > dataEnd) return 0;
        tl += tdel;
        ieprev = ie;    /* structure assignment */
   
  @@ .
  patch -p0 <<'@@ .'
  Index: rpm/rpmdb/legacy.c
  ============================================================================
  $ cvs diff -u -r1.36 -r1.37 legacy.c
  --- rpm/rpmdb/legacy.c        14 Nov 2007 21:13:18 -0000      1.36
  +++ rpm/rpmdb/legacy.c        27 Nov 2007 02:29:27 -0000      1.37
  @@ -49,12 +49,12 @@
   {
   /[EMAIL PROTECTED]@*/
       static const char * cmd = NULL;
  -    static int initted = 0;
  +    static int oneshot = 0;
       int fdno;
   
  -    if (!initted) {
  +    if (!oneshot) {
        cmd = rpmExpand("%{?__prelink_undo_cmd}", NULL);
  -     initted++;
  +     oneshot++;
       }
   
       if (pidp) *pidp = 0;
  @@ .
______________________________________________________________________
RPM Package Manager                                    http://rpm5.org
CVS Sources Repository                                rpm-cvs@rpm5.org

Reply via email to