RPM Community Forums

Mailing List Message of <rpm-cvs>

[CVS] RPM: rpm/rpmdb/ fprint.c hdrNVR.c pkgio.c signature.c

From: Jeff Johnson <jbj@rpm5.org>
Date: Sat 13 Oct 2007 - 02:27:17 CEST
Message-Id: <20071013002717.B12FF34845A@rpm5.org>
  RPM Package Manager, CVS Repository
  http://rpm5.org/cvs/
  ____________________________________________________________________________

  Server: rpm5.org                         Name:   Jeff Johnson
  Root:   /v/rpm/cvs                       Email:  jbj@rpm5.org
  Module: rpm                              Date:   13-Oct-2007 02:27:17
  Branch: HEAD                             Handle: 2007101301271700

  Modified files:
    rpm/rpmdb               fprint.c hdrNVR.c pkgio.c signature.c

  Log:
    - jbj: fprint.c: use headerGetExtension everywhere.
    - jbj: hdrNVR.c: use headerGetExtension everywhere.
    - jbj: pkgio.c: use headerGetExtension everywhere.
    - jbj: signature.c: use headerGetExtension everywhere.

  Summary:
    Revision    Changes     Path
    1.16        +25 -10     rpm/rpmdb/fprint.c
    1.12        +22 -26     rpm/rpmdb/hdrNVR.c
    1.15        +25 -21     rpm/rpmdb/pkgio.c
    1.7         +11 -6      rpm/rpmdb/signature.c
  ____________________________________________________________________________

  patch -p0 <<'@@ .'
  Index: rpm/rpmdb/fprint.c
  ============================================================================
  $ cvs diff -u -r1.15 -r1.16 fprint.c
  --- rpm/rpmdb/fprint.c	30 Sep 2007 17:29:05 -0000	1.15
  +++ rpm/rpmdb/fprint.c	13 Oct 2007 00:27:17 -0000	1.16
  @@ -248,21 +248,36 @@
   void fpLookupHeader(fingerPrintCache cache, Header h, fingerPrint * fpList)
   	/*@modifies h, cache, *fpList @*/;
   {
  -    HGE_t hge = (HGE_t)headerGetEntryMinMemory;
  -    HFD_t hfd = headerFreeData;
  -    const char ** baseNames, ** dirNames;
  -    rpmTagType bnt, dnt;
  -    int_32 * dirIndexes;
  +    HGE_t hge = (HGE_t)headerGetExtension;
  +    int_32 he_t = 0;
  +    hRET_t he_p = { .ptr = NULL };
  +    int_32 he_c = 0;
  +    HE_s he_s = { .tag = 0, .t = &he_t, .p = &he_p, .c = &he_c, .freeData = 0 };
  +    HE_t he = &he_s;
  +    const char ** baseNames;
  +    const char ** dirNames;
  +    uint_32 * dirIndexes;
       int fileCount;
       int xx;
   
  -    if (!hge(h, RPMTAG_BASENAMES, &bnt, (void **) &baseNames, &fileCount))
  +    he->tag = RPMTAG_BASENAMES;
  +    xx = hge(h, he->tag, he->t, he->p, he->c);)
  +    baseNames = he_p.argv;
  +    fileCount = he_c;
  +    if (!xx)
   	return;
   
  -    xx = hge(h, RPMTAG_DIRNAMES, &dnt, (void **) &dirNames, NULL);
  -    xx = hge(h, RPMTAG_DIRINDEXES, NULL, (void **) &dirIndexes, NULL);
  +    he->tag = RPMTAG_DIRNAMES;
  +    xx = hge(h, he->tag, he->t, he->p, he->c);)
  +    dirNames = he_p.argv;
  +    he->tag = RPMTAG_DIRINDEXES;
  +    xx = hge(h, he->tag, he->t, he->p, he->c);)
  +    dirIndexes = he_p.ui32p;
  +
       fpLookupList(cache, dirNames, baseNames, dirIndexes, fileCount, fpList);
  -    dirNames = hfd(dirNames, dnt);
  -    baseNames = hfd(baseNames, bnt);
  +
  +    dirIndexes = _free(dirIndexes);
  +    dirNames = _free(dirNames);
  +    baseNames = _free(baseNames);
   }
   #endif
  @@ .
  patch -p0 <<'@@ .'
  Index: rpm/rpmdb/hdrNVR.c
  ============================================================================
  $ cvs diff -u -r1.11 -r1.12 hdrNVR.c
  --- rpm/rpmdb/hdrNVR.c	30 Sep 2007 17:29:05 -0000	1.11
  +++ rpm/rpmdb/hdrNVR.c	13 Oct 2007 00:27:17 -0000	1.12
  @@ -35,16 +35,14 @@
   	/*@globals rpmGlobalMacroContext @*/
   	/*@modifies rpmGlobalMacroContext @*/
   {
  +    HGE_t hge = (HGE_t)headerGetExtension;
  +    int_32 he_t = 0;
  +    hRET_t he_p = { .ptr = NULL };
  +    int_32 he_c = 0;
  +    HE_s he_s = { .tag = 0, .t = &he_t, .p = &he_p, .c = &he_c, .freeData = 0 };
  +    HE_t he = &he_s;
       struct tagMacro * tagm;
  -    union {
  -	const void * ptr;
  -/*@unused@*/
  -	const char ** argv;
  -	const char * str;
  -	int_32 * i32p;
  -    } body;
       char numbuf[32];
  -    int_32 type;
       int xx;
   
       /* XXX pre-expand %{buildroot} (if any) */
  @@ -60,22 +58,21 @@
       }
   
       for (tagm = tagMacros; tagm->macroname != NULL; tagm++) {
  -	xx = headerGetEntryMinMemory(h, tagm->tag, &type, (hPTR_t *) &body.ptr, NULL);
  +	he->tag = tagm->tag;
  +	xx = hge(h, he->tag, he->t, he->p, he->c);
   	if (!xx)
   	    continue;
  -	switch (type) {
  +	switch (he_t) {
   	case RPM_INT32_TYPE:
  -	    sprintf(numbuf, "%d", *body.i32p);
  +	    sprintf(numbuf, "%d", *he_p.i32p);
   	    addMacro(NULL, tagm->macroname, NULL, numbuf, -1);
   	    /*@switchbreak@*/ break;
   	case RPM_STRING_TYPE:
  -	    addMacro(NULL, tagm->macroname, NULL, body.str, -1);
  +	    addMacro(NULL, tagm->macroname, NULL, he_p.str, -1);
   	    /*@switchbreak@*/ break;
   	case RPM_STRING_ARRAY_TYPE:
   	case RPM_I18NSTRING_TYPE:
   	case RPM_BIN_TYPE:
  -	    body.ptr = headerFreeData(body.ptr, type);
  -	    /*@fallthrough@*/
   	case RPM_NULL_TYPE:
   	case RPM_CHAR_TYPE:
   	case RPM_INT8_TYPE:
  @@ -83,6 +80,7 @@
   	default:
   	    /*@switchbreak@*/ break;
   	}
  +	he_p.ptr = _free(he_p.ptr);
       }
       return 0;
   }
  @@ -93,22 +91,21 @@
   	/*@globals rpmGlobalMacroContext @*/
   	/*@modifies rpmGlobalMacroContext @*/
   {
  +    HGE_t hge = (HGE_t)headerGetExtension;
  +    int_32 he_t = 0;
  +    hRET_t he_p = { .ptr = NULL };
  +    int_32 he_c = 0;
  +    HE_s he_s = { .tag = 0, .t = &he_t, .p = &he_p, .c = &he_c, .freeData = 0 };
  +    HE_t he = &he_s;
       struct tagMacro * tagm;
  -    union {
  -	const void * ptr;
  -/*@unused@*/
  -	const char ** argv;
  -	const char * str;
  -	int_32 * i32p;
  -    } body;
  -    int_32 type;
       int xx;
   
       for (tagm = tagMacros; tagm->macroname != NULL; tagm++) {
  -	xx = headerGetEntryMinMemory(h, tagm->tag, &type, (hPTR_t *) &body.ptr, NULL);
  +	he->tag = tagm->tag;
  +	xx = hge(h, he->tag, he->t, he->p, he->c);
   	if (!xx)
   	    continue;
  -	switch (type) {
  +	switch (he_t) {
   	case RPM_INT32_TYPE:
   	    delMacro(NULL, tagm->macroname);
   	    /*@switchbreak@*/ break;
  @@ -118,8 +115,6 @@
   	case RPM_STRING_ARRAY_TYPE:
   	case RPM_I18NSTRING_TYPE:
   	case RPM_BIN_TYPE:
  -	    body.ptr = headerFreeData(body.ptr, type);
  -	    /*@fallthrough@*/
   	case RPM_NULL_TYPE:
   	case RPM_CHAR_TYPE:
   	case RPM_INT8_TYPE:
  @@ -127,6 +122,7 @@
   	default:
   	    /*@switchbreak@*/ break;
   	}
  +	he_p.ptr = _free(he_p.ptr);
       }
   
       /* XXX restore previous %{buildroot} (if any) */
  @@ .
  patch -p0 <<'@@ .'
  Index: rpm/rpmdb/pkgio.c
  ============================================================================
  $ cvs diff -u -r1.14 -r1.15 pkgio.c
  --- rpm/rpmdb/pkgio.c	11 Oct 2007 19:44:24 -0000	1.14
  +++ rpm/rpmdb/pkgio.c	13 Oct 2007 00:27:17 -0000	1.15
  @@ -73,6 +73,12 @@
   
   rpmRC rpmtsFindPubkey(rpmts ts, void * _dig)
   {
  +    HGE_t hge = (HGE_t)headerGetExtension;
  +    int_32 he_t = 0;
  +    hRET_t he_p = { .ptr = NULL };
  +    int_32 he_c = 0;
  +    HE_s he_s = { .tag = 0, .t = &he_t, .p = &he_p, .c = &he_c, .freeData = 0 };
  +    HE_t he = &he_s;
       pgpDig dig = (_dig ? _dig : rpmtsDig(ts));
       const void * sig = pgpGetSig(dig);
       pgpDigParams sigp = pgpGetSignature(dig);
  @@ -84,16 +90,11 @@
   #endif
       int xx;
   
  -#ifdef	DYING
  -    if (sig == NULL || dig == NULL || sigp == NULL || pubp == NULL)
  -	goto exit;
  -#else
   assert(sig != NULL);
   assert(dig != NULL);
   assert(sigp != NULL);
   assert(pubp != NULL);
   assert(rpmtsDig(ts) == dig);
  -#endif
   
   #if 0
   fprintf(stderr, "==> find sig id %08x %08x ts pubkey id %08x %08x\n",
  @@ -152,21 +153,19 @@
   	Header h;
   
   	/* Retrieve the pubkey that matches the signature. */
  +	he->tag = RPMTAG_PUBKEYS;
   	mi = rpmdbInitIterator(rpmtsGetRdb(ts), RPMTAG_PUBKEYS, sigp->signid, sizeof(sigp->signid));
   	while ((h = rpmdbNextIterator(mi)) != NULL) {
  -	    const char ** pubkeys;
  -	    int_32 pt, pc;
  -
  -	    if (!headerGetEntry(h, RPMTAG_PUBKEYS, &pt, &pubkeys, &pc))
  +	    if (!hge(h, he->tag, he->t, he->p, he->c))
   		continue;
   	    hx = rpmdbGetIteratorOffset(mi);
   	    ix = rpmdbGetIteratorFileNum(mi);
   /*@-moduncon -nullstate @*/
  -	    if (ix >= pc
  -	     || b64decode(pubkeys[ix], (void **) &ts->pkpkt, &ts->pkpktlen))
  +	    if (ix >= he_c
  +	     || b64decode(he_p.argv[ix], (void **) &ts->pkpkt, &ts->pkpktlen))
   		ix = -1;
   /*@=moduncon =nullstate @*/
  -	    pubkeys = headerFreeData(pubkeys, pt);
  +	    he_p.ptr = _free(he_p.ptr);
   	    break;
   	}
   	mi = rpmdbFreeIterator(mi);
  @@ -294,10 +293,8 @@
       int ret = 0;
       if (ts != NULL) {
   	const void * osig = pgpGetSig(rpmtsDig(ts));
  -	int_32 osigtype = pgpGetSigtype(rpmtsDig(ts));
   /*@-modobserver -observertrans -dependenttrans @*/	/* FIX: pgpSetSig() lazy free. */
  -	if (osig && osigtype)
  -	    osig = headerFreeData(osig, osigtype);
  +	osig = _free(osig);
   /*@=modobserver =observertrans =dependenttrans @*/
   	ret = pgpSetSig(rpmtsDig(ts), sigtag, sigtype, sig, siglen);
       }
  @@ -557,6 +554,12 @@
   	/*@globals fileSystem @*/
   	/*@modifies *ptr, *msg, fileSystem @*/
   {
  +    HGE_t hge = (HGE_t)headerGetExtension;
  +    int_32 he_t = 0;
  +    hRET_t he_p = { .ptr = NULL };
  +    int_32 he_c = 0;
  +    HE_s he_s = { .tag = 0, .t = &he_t, .p = &he_p, .c = &he_c, .freeData = 0 };
  +    HE_t he = &he_s;
       Header * sighp = ptr;
       char buf[BUFSIZ];
       int_32 block[4];
  @@ -712,7 +715,6 @@
   
       {	int sigSize = headerSizeof(sigh);
   	int pad = (8 - (sigSize % 8)) % 8; /* 8-byte pad */
  -	int_32 * archSize = NULL;
   
   	/* Position at beginning of header. */
   	if (pad && (xx = timedRead(fd, (void *)block, pad)) != pad) {
  @@ -722,13 +724,17 @@
   	}
   
   	/* Print package component sizes. */
  -	if (headerGetEntry(sigh, RPMSIGTAG_SIZE, NULL, &archSize, NULL)) {
  -	    size_t datasize = *(uint_32 *)archSize;
  +
  +	he->tag = RPMSIGTAG_SIZE;
  +	xx = hge(sigh, he->tag, he->t, he->p, he->c);
  +	if (xx) {
  +	    size_t datasize = *he_p.ui32p;
   	    rc = printSize(fd, sigSize, pad, datasize);
   	    if (rc != RPMRC_OK)
   		(void) snprintf(buf, sizeof(buf),
   			_("sigh sigSize(%d): BAD, fstat(2) failed\n"), sigSize);
   	}
  +	he_p.ptr = _free(he_p.ptr);
       }
   
   exit:
  @@ -950,10 +956,8 @@
       sig = memcpy(xmalloc(siglen), dataStart + info->offset, siglen);
       {
   	const void * osig = pgpGetSig(dig);
  -	int_32 osigtype = pgpGetSigtype(dig);
   /*@-modobserver -observertrans -dependenttrans @*/	/* FIX: pgpSetSig() lazy free. */
  -	if (osig && osigtype)
  -	    osig = headerFreeData(osig, osigtype);
  +	osig = _free(osig);
   /*@=modobserver =observertrans =dependenttrans @*/
   	(void) pgpSetSig(dig, info->tag, info->type, sig, info->count);
       }
  @@ .
  patch -p0 <<'@@ .'
  Index: rpm/rpmdb/signature.c
  ============================================================================
  $ cvs diff -u -r1.6 -r1.7 signature.c
  --- rpm/rpmdb/signature.c	11 Oct 2007 19:44:24 -0000	1.6
  +++ rpm/rpmdb/signature.c	13 Oct 2007 00:27:17 -0000	1.7
  @@ -523,6 +523,12 @@
   	/*@globals rpmGlobalMacroContext, h_errno, fileSystem, internalState @*/
   	/*@modifies sigh, sigTag, rpmGlobalMacroContext, fileSystem, internalState @*/
   {
  +    HGE_t hge = (HGE_t)headerGetExtension;
  +    int_32 he_t = 0;
  +    hRET_t he_p = { .ptr = NULL };
  +    int_32 he_c = 0;
  +    HE_s he_s = { .tag = 0, .t = &he_t, .p = &he_p, .c = &he_c, .freeData = 0 };
  +    HE_t he = &he_s;
       Header h = NULL;
       FD_t fd = NULL;
       byte * pkt;
  @@ -552,11 +558,10 @@
   	    unsigned char * hmagic = NULL;
   	    size_t nmagic = 0;
   	    DIGEST_CTX ctx;
  -	    void * uh;
  -	    int_32 uht, uhc;
   	
  -	    if (!headerGetEntry(h, RPMTAG_HEADERIMMUTABLE, &uht, &uh, &uhc)
  -	     ||  uh == NULL)
  +	    he->tag = RPMTAG_HEADERIMMUTABLE;
  +	    if (!hge(h, he->tag, he->t, he->p, he->c)
  +	     ||  he_p.ptr == NULL)
   	    {
   		h = headerFree(h);
   		goto exit;
  @@ -565,9 +570,9 @@
   	    ctx = rpmDigestInit(PGPHASHALGO_SHA1, RPMDIGEST_NONE);
   	    if (hmagic && nmagic > 0)
   		(void) rpmDigestUpdate(ctx, hmagic, nmagic);
  -	    (void) rpmDigestUpdate(ctx, uh, uhc);
  +	    (void) rpmDigestUpdate(ctx, he_p.ptr, he_c);
   	    (void) rpmDigestFinal(ctx, &SHA1, NULL, 1);
  -	    uh = headerFreeData(uh, uht);
  +	    he_p.ptr = _free(he_p.ptr);
   	}
   	h = headerFree(h);
   
  @@ .
Received on Sat Oct 13 02:27:17 2007
Driven by Jeff Johnson and the RPM project team.
Hosted by OpenPKG and Ralf S. Engelschall.
Powered by FreeBSD and OpenPKG.