RPM Community Forums

Mailing List Message of <rpm-devel>

Re: [CVS] RPM: rpm/ CHANGES rpm/rpmdb/ .splintrc hdrinline.h header.c head...

From: Jeff Johnson <n3npq@mac.com>
Date: Fri 16 Nov 2007 - 00:27:09 CET
Message-Id: <3EC6E89A-8A14-4317-BC42-39173EF83D17@mac.com>
This patch likely needs some explanation too.

Handling both RPMv3 (aka LSB) format as well as RPMv4 format
transparently was one of the hardest rpm hacks I've ever had to do.

This patch reverts the worst damage from that hack, isolating a few  
remaining
issues with the variables marked "int_32" and some assertions within  
rpmdb/header.c that
I will mop up shortly.

I've tested that HEAD can do the following sequence
     build a *.rpm
     sign a *.rpm
     verify a *.rpm
     query a *.rpm
     erase an installed package
     install a *.rpm
     query the installed package
     verify the installed package
with valgrind (there's a minor memory leak erasing a package).

The patch has been extensively checked with splint annotations as well.

But one never knows ...

If I made a mistake, this is the likeliest check-in where the mistake  
is.

73 de Jeff


On Nov 15, 2007, at 6:14 PM, Jeff Johnson wrote:

>   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:   16-Nov-2007  
> 00:14:54
>   Branch: HEAD                             Handle: 2007111523145201
>
>   Modified files:
>     rpm                     CHANGES
>     rpm/rpmdb               .splintrc hdrinline.h header.c header.h
>                             header_internal.c header_internal.h  
> pkgio.c
>
>   Log:
>     - rpmdb: casts for integral conversions.
>
>   Summary:
>     Revision    Changes     Path
>     1.1830      +1  -0      rpm/CHANGES
>     1.13        +1  -1      rpm/rpmdb/.splintrc
>     1.32        +3  -3      rpm/rpmdb/hdrinline.h
>     1.121       +77 -62     rpm/rpmdb/header.c
>     1.66        +3  -3      rpm/rpmdb/header.h
>     1.16        +3  -2      rpm/rpmdb/header_internal.c
>     1.31        +4  -4      rpm/rpmdb/header_internal.h
>     1.36        +13 -10     rpm/rpmdb/pkgio.c
>    
> ______________________________________________________________________ 
> ______
>
>   patch -p0 <<'@@ .'
>   Index: rpm/CHANGES
>    
> ====================================================================== 
> ======
>   $ cvs diff -u -r1.1829 -r1.1830 CHANGES
>   --- rpm/CHANGES	15 Nov 2007 20:26:03 -0000	1.1829
>   +++ rpm/CHANGES	15 Nov 2007 23:14:52 -0000	1.1830
>   @@ -1,4 +1,5 @@
>    5.0a1 -> 5.0a2:
>   +    - jbj: rpmdb: casts for integral conversions.
>        - jbj: lib: identify and repair several minor flaws caught  
> by splint.
>        - jbj: rpmio: casts for integral conversions.
>        - jbj: rpmio: casts for character <-> integral conversions.
>   @@ .
>   patch -p0 <<'@@ .'
>   Index: rpm/rpmdb/.splintrc
>    
> ====================================================================== 
> ======
>   $ cvs diff -u -r1.12 -r1.13 .splintrc
>   --- rpm/rpmdb/.splintrc	15 Nov 2007 14:30:25 -0000	1.12
>   +++ rpm/rpmdb/.splintrc	15 Nov 2007 23:14:53 -0000	1.13
>   @@ -62,4 +62,4 @@
>    -boolops		# 136
>    +boolint		# 407
>    +ignorequals		# 165
>   -+matchanyintegral	# 23
>   +#+matchanyintegral	# 23
>   @@ .
>   patch -p0 <<'@@ .'
>   Index: rpm/rpmdb/hdrinline.h
>    
> ====================================================================== 
> ======
>   $ cvs diff -u -r1.31 -r1.32 hdrinline.h
>   --- rpm/rpmdb/hdrinline.h	14 Nov 2007 01:17:52 -0000	1.31
>   +++ rpm/rpmdb/hdrinline.h	15 Nov 2007 23:14:53 -0000	1.32
>   @@ -116,7 +116,7 @@
>     * @return		size of on-disk header
>     */
>    /*@unused@*/ static inline
>   -unsigned int headerSizeof(/*@null@*/ Header h)
>   +size_t headerSizeof(/*@null@*/ Header h)
>    	/*@modifies h @*/
>    {
>        /*@-abstract@*/
>   @@ -659,7 +659,7 @@
>     * @return		header instance
>     */
>    /*@unused@*/ static inline
>   -int headerGetInstance(/*@null@*/ Header h)
>   +uint32_t headerGetInstance(/*@null@*/ Header h)
>    	/*@*/
>    {
>        return hdrVec->hdrgetinstance(h);
>   @@ -672,7 +672,7 @@
>     * @return		0 always
>     */
>    /*@unused@*/ static inline
>   -int headerSetInstance(/*@null@*/ Header h, int instance)
>   +uint32_t headerSetInstance(/*@null@*/ Header h, uint32_t instance)
>    	/*@modifies h @*/
>    {
>        return hdrVec->hdrsetinstance(h, instance);
>   @@ .
>   patch -p0 <<'@@ .'
>   Index: rpm/rpmdb/header.c
>    
> ====================================================================== 
> ======
>   $ cvs diff -u -r1.120 -r1.121 header.c
>   --- rpm/rpmdb/header.c	15 Nov 2007 14:30:25 -0000	1.120
>   +++ rpm/rpmdb/header.c	15 Nov 2007 23:14:53 -0000	1.121
>   @@ -261,7 +261,7 @@
>
>        if (h->index) {
>    	indexEntry entry = h->index;
>   -	int i;
>   +	size_t i;
>    	for (i = 0; i < h->indexUsed; i++, entry++) {
>    	    if ((h->flags & HEADERFLAG_ALLOCATED) && ENTRY_IS_REGION 
> (entry)) {
>    		if (entry->length > 0) {
>   @@ -384,13 +384,13 @@
>     * @return		size of on-disk header
>     */
>    static
>   -unsigned int headerSizeof(/*@null@*/ Header h)
>   +size_t headerSizeof(/*@null@*/ Header h)
>    	/*@modifies h @*/
>    {
>        indexEntry entry;
>   -    unsigned int size = 0;
>   -    unsigned int pad = 0;
>   -    int i;
>   +    size_t size = 0;
>   +    size_t pad = 0;
>   +    size_t i;
>
>        if (h == NULL)
>    	return size;
>   @@ -404,7 +404,7 @@
>        /*@=sizeoftype@*/
>
>        for (i = 0, entry = h->index; i < h->indexUsed; i++, entry++) {
>   -	unsigned diff;
>   +	size_t diff;
>    	rpmTagType type;
>
>    	/* Regions go in as is ... */
>   @@ -525,10 +525,10 @@
>     * @param dataStart	header data start
>     * @param dataEnd	header data end
>     * @param regionid	region offset
>   - * @return		no. bytes of data in region, -1 on error
>   + * @return		no. bytes of data in region, 0 on error
>     */
>    /*@-globs@*/	/* XXX rpm_typeAlign usage */
>   -static int regionSwab(/*@null@*/ indexEntry entry, int il, int dl,
>   +static uint32_t regionSwab(/*@null@*/ indexEntry entry, uint32_t  
> il, uint32_t dl,
>    		entryInfo pe,
>    		unsigned char * dataStart,
>    		/*@null@*/ const unsigned char * dataEnd,
>   @@ -540,7 +540,7 @@
>        unsigned char * tprev = NULL;
>        unsigned char * t = NULL;
>        size_t tdel = 0;
>   -    int tl = dl;
>   +    size_t tl = dl;
>        struct indexEntry_s ieprev;
>
>        memset(&ieprev, 0, sizeof(ieprev));
>   @@ -551,7 +551,8 @@
>    	ie.info.tag = (uint32_t) ntohl(pe->tag);
>    	ie.info.type = (uint32_t) ntohl(pe->type);
>    	ie.info.count = (uint32_t) ntohl(pe->count);
>   -	ie.info.offset = ntohl(pe->offset);
>   +	ie.info.offset = (int_32) ntohl(pe->offset);
>   +assert(ie.info.offset >= 0);	/* XXX insurance */
>
>    	if (hdrchkType(ie.info.type))
>    	    return -1;
>   @@ -587,8 +588,7 @@
>    	/* Alignment */
>    	type = ie.info.type;
>    	if (typeSizes[type] > 1) {
>   -	    unsigned diff;
>   -	    diff = typeSizes[type] - (dl % typeSizes[type]);
>   +	    size_t diff = typeSizes[type] - (dl % typeSizes[type]);
>    	    if (diff != typeSizes[type]) {
>    		dl += diff;
>    		if (ieprev.info.type == RPM_I18NSTRING_TYPE)
>   @@ -693,9 +693,11 @@
>        uint32_t dl = 0;
>        indexEntry entry;
>        rpmTagType type;
>   -    int i;
>   -    int drlen, ndribbles;
>   -    int driplen, ndrips;
>   +    size_t i;
>   +    size_t drlen;
>   +    size_t ndribbles;
>   +    size_t driplen;
>   +    size_t ndrips;
>        int legacy = 0;
>
>        if ((sw = headerGetStats(h, 18)) != NULL)	/*  
> RPMTS_OP_HDRLOAD */
>   @@ -709,9 +711,14 @@
>        drlen = ndribbles = driplen = ndrips = 0;
>        for (i = 0, entry = h->index; i < h->indexUsed; i++, entry++) {
>    	if (ENTRY_IS_REGION(entry)) {
>   -	    int_32 rdl = -entry->info.offset;	/* negative offset */
>   -	    int_32 ril = rdl/sizeof(*pe);
>   -	    int rid = entry->info.offset;
>   +	    uint32_t rdl;
>   +	    uint32_t ril;
>   +	    int_32 rid;
>   +
>   +assert(entry->info.offset <= 0);	/* XXX insurance */
>   +	    rdl = -entry->info.offset;	/* negative offset */
>   +	    ril = rdl/sizeof(*pe);
>   +	    rid = entry->info.offset;
>
>    	    il += ril;
>    	    dl += entry->rdlen + entry->info.count;
>   @@ -727,8 +734,7 @@
>    		/* Alignment */
>    		type = entry->info.type;
>    		if (typeSizes[type] > 1) {
>   -		    unsigned diff;
>   -		    diff = typeSizes[type] - (dl % typeSizes[type]);
>   +		    size_t diff = typeSizes[type] - (dl % typeSizes[type]);
>    		    if (diff != typeSizes[type]) {
>    			drlen += diff;
>    			pad += diff;
>   @@ -753,8 +759,7 @@
>    	/* Alignment */
>    	type = entry->info.type;
>    	if (typeSizes[type] > 1) {
>   -	    unsigned diff;
>   -	    diff = typeSizes[type] - (dl % typeSizes[type]);
>   +	    size_t diff = typeSizes[type] - (dl % typeSizes[type]);
>    	    if (diff != typeSizes[type]) {
>    		driplen += diff;
>    		pad += diff;
>   @@ -798,27 +803,33 @@
>    	pe->count = (uint32_t) htonl(entry->info.count);
>
>    	if (ENTRY_IS_REGION(entry)) {
>   -	    int_32 rdl = -entry->info.offset;	/* negative offset */
>   -	    int_32 ril = rdl/sizeof(*pe) + ndribbles;
>   -	    int rid = entry->info.offset;
>   +	    uint32_t rdl;
>   +	    uint32_t ril;
>   +	    int_32 rid;
>   +
>   +assert(entry->info.offset <= 0);	/* XXX insurance */
>   +
>   +	    rdl = -entry->info.offset;	/* negative offset */
>   +	    ril = rdl/sizeof(*pe) + ndribbles;
>   +	    rid = entry->info.offset;
>
>    	    src = (char *)entry->data;
>    	    rdlen = entry->rdlen;
>
>    	    /* XXX Legacy regions do not include the region tag and  
> data. */
>    	    if (i == 0 && (h->flags & HEADERFLAG_LEGACY)) {
>   -		int32_t stei[4];	/* FIXME uint32_t */
>   +		uint32_t stei[4];
>
>    		legacy = 1;
>    		memcpy(pe+1, src, rdl);
>    		memcpy(te, src + rdl, rdlen);
>    		te += rdlen;
>
>   -		pe->offset = htonl(te - dataStart);
>   -		stei[0] = (int32_t) pe->tag;
>   -		stei[1] = (int32_t) pe->type;
>   -		stei[2] = (int32_t) htonl(-rdl-entry->info.count);
>   -		stei[3] = (int32_t) pe->count;
>   +		pe->offset = (int_32) htonl(te - dataStart);
>   +		stei[0] = (uint32_t) pe->tag;
>   +		stei[1] = (uint32_t) pe->type;
>   +		stei[2] = (uint32_t) htonl(-rdl-entry->info.count);
>   +		stei[3] = (uint32_t) pe->count;
>    		memcpy(te, stei, entry->info.count);
>    		te += entry->info.count;
>    		ril++;
>   @@ -836,8 +847,9 @@
>    		{   /*@-castexpose@*/
>    		    entryInfo se = (entryInfo)src;
>    		    /*@=castexpose@*/
>   -		    int off = ntohl(se->offset);
>   -		    pe->offset = (off) ? htonl(te - dataStart) : htonl(off);
>   +		    int_32 off = (int_32) ntohl(se->offset);
>   +		    pe->offset = (int_32)((off)
>   +			? htonl(te - dataStart) : htonl(off));
>    		}
>    		te += entry->info.count + drlen;
>
>   @@ -873,7 +885,7 @@
>    	    }
>    	}
>
>   -	pe->offset = htonl(te - dataStart);
>   +	pe->offset = (int_32) htonl(te - dataStart);
>
>    	/* copy data w/ endian conversions */
>    	switch (entry->info.type) {
>   @@ -1066,7 +1078,7 @@
>        unsigned char * dataStart;
>        unsigned char * dataEnd;
>        indexEntry entry;
>   -    int rdlen;
>   +    uint32_t rdlen;
>        int i;
>
>        /* Sanity checks on header intro. */
>   @@ -1123,8 +1135,8 @@
>    	entry++;
>    	h->indexUsed++;
>        } else {
>   -	int_32 rdl;
>   -	int_32 ril;
>   +	uint32_t rdl;
>   +	uint32_t ril;
>
>    	h->flags &= ~HEADERFLAG_LEGACY;
>
>   @@ -1136,7 +1148,7 @@
>    	if (hdrchkTags(entry->info.count))
>    	    goto errxit;
>
>   -	{   int off = ntohl(pe->offset);
>   +	{   int_32 off = (int_32) ntohl(pe->offset);
>
>    	    if (hdrchkData(off))
>    		goto errxit;
>   @@ -1144,12 +1156,13 @@
>    /*@-sizeoftype@*/
>    		size_t nb = REGION_TAG_COUNT;
>    /*@=sizeoftype@*/
>   -		int32_t * stei = memcpy(alloca(nb), dataStart + off, nb);
>   +		uint32_t * stei = memcpy(alloca(nb), dataStart + off, nb);
>    		rdl = -ntohl(stei[2]);	/* negative offset */
>   +assert((int_32)rdl >= 0);	/* XXX insurance */
>    		ril = rdl/sizeof(*pe);
>    		if (hdrchkTags(ril) || hdrchkData(rdl))
>    		    goto errxit;
>   -		entry->info.tag = htonl(pe->tag);
>   +		entry->info.tag = (uint32_t) htonl(pe->tag);
>    	    } else {
>    		ril = il;
>    		/*@-sizeoftype@*/
>   @@ -1158,32 +1171,32 @@
>    		entry->info.tag = HEADER_IMAGE;
>    	    }
>    	}
>   -	entry->info.offset = -rdl;	/* negative offset */
>   +	entry->info.offset = (int_32) -rdl;	/* negative offset */
>
>    	/*@-assignexpose@*/
>    	entry->data = pe;
>    	/*@=assignexpose@*/
>    	entry->length = pvlen - sizeof(il) - sizeof(dl);
>   -	rdlen = regionSwab(entry+1, ril-1, 0, pe+1, dataStart, dataEnd,  
> entry->info.offset);
>   -	if (rdlen < 0)
>   +	rdlen = regionSwab(entry+1, (ril-1), 0, pe+1, dataStart,  
> dataEnd, entry->info.offset);
>   +	if (rdlen == 0)
>    	    goto errxit;
>    	entry->rdlen = rdlen;
>
>    	if (ril < h->indexUsed) {
>    	    indexEntry newEntry = entry + ril;
>   -	    int ne = (h->indexUsed - ril);
>   -	    int rid = entry->info.offset+1;
>   -	    int rc;
>   +	    size_t ne = (h->indexUsed - ril);
>   +	    int_32 rid = entry->info.offset+1;
>   +	    uint32_t rc;
>
>    	    /* Load dribble entries from region. */
>    	    rc = regionSwab(newEntry, ne, 0, pe+ril, dataStart,  
> dataEnd, rid);
>   -	    if (rc < 0)
>   +	    if (rc == 0)
>    		goto errxit;
>    	    rdlen += rc;
>
>    	  { indexEntry firstEntry = newEntry;
>   -	    int save = h->indexUsed;
>   -	    int j;
>   +	    size_t save = h->indexUsed;
>   +	    size_t j;
>
>    	    /* Dribble entries replace duplicate region entries. */
>    	    h->indexUsed -= ne;
>   @@ -1302,7 +1315,7 @@
>     * @return		header instance
>     */
>    static
>   -int headerGetInstance(/*@null@*/ Header h)
>   +uint32_t headerGetInstance(/*@null@*/ Header h)
>    	/*@*/
>    {
>        return (h != NULL ? h->instance : 0);
>   @@ -1315,7 +1328,7 @@
>     * @return		0 always
>     */
>    static
>   -int headerSetInstance(/*@null@*/ Header h, int instance)
>   +uint32_t headerSetInstance(/*@null@*/ Header h, uint32_t instance)
>    	/*@modifies h @*/
>    {
>        if (h != NULL)
>   @@ -1362,7 +1375,7 @@
>    	xx = headerSetOrigin(nh, origin);
>    	origin = _free(origin);
>        }
>   -    xx = headerSetInstance(nh, instance);
>   +    xx = (int) headerSetInstance(nh, instance);
>        return nh;
>    }
>
>   @@ -1555,6 +1568,7 @@
>    	/*@requires maxSet(type) >= 0 /\ maxSet(p) >= 0 /\ maxSet(c) >=  
> 0 @*/
>    {
>        rpmTagCount count = entry->info.count;
>   +    uint32_t rdlen;
>        int rc = 1;		/* XXX 1 on success. */
>
>        if (p)
>   @@ -1572,9 +1586,12 @@
>    	    entryInfo pe = (entryInfo) (ei + 2);
>    	    /*@=castexpose@*/
>    	    unsigned char * dataStart = (unsigned char *) (pe + ntohl(ei 
> [0]));
>   -	    int32_t rdl = -entry->info.offset;	/* negative offset */
>   -	    int32_t ril = rdl/sizeof(*pe);
>   +	    uint32_t rdl;
>   +	    uint32_t ril;
>
>   +assert(entry->info.offset <= 0);		/* XXX insurance */
>   +	    rdl = -entry->info.offset;	/* negative offset */
>   +	    ril = rdl/sizeof(*pe);
>    	    /*@-sizeoftype@*/
>    	    rdl = entry->rdlen;
>    	    count = 2 * sizeof(*ei) + (ril * sizeof(*pe)) + rdl;
>   @@ -1597,9 +1614,9 @@
>    	    dataStart = (unsigned char *) memcpy(pe + ril, dataStart,  
> rdl);
>    	    /*@=sizeoftype@*/
>
>   -	    rc = regionSwab(NULL, ril, 0, pe, dataStart, NULL, 0);
>   +	    rdlen = regionSwab(NULL, ril, 0, pe, dataStart, NULL, 0);
>    	    /* XXX 1 on success. */
>   -	    rc = (rc < 0) ? 0 : 1;
>   +	    rc = (rdlen == 0) ? 0 : 1;
>    	} else {
>    	    count = entry->length;
>    	    (*p).ptr = (!minMem
>   @@ -2484,10 +2501,8 @@
>     * Header tag iterator data structure.
>     */
>    struct headerIterator_s {
>   -/*@unused@*/
>        Header h;		/*!< Header being iterated. */
>   -/*@unused@*/
>   -    int next_index;	/*!< Next tag index. */
>   +    size_t next_index;	/*!< Next tag index. */
>    };
>
>    /** \ingroup header
>   @@ -2545,7 +2560,7 @@
>    {
>        void * sw;
>        Header h = hi->h;
>   -    int slot = hi->next_index;
>   +    size_t slot = hi->next_index;
>        indexEntry entry = NULL;
>        int rc;
>
>   @@ -2621,7 +2636,7 @@
>        size_t vallen;
>        size_t alloced;
>        size_t numTokens;
>   -    int i;
>   +    size_t i;
>    } * headerSprintfArgs;
>
>    /**
>   @@ -2666,7 +2681,7 @@
>    	    ? &hsa->format->u.array.format->u.tag :
>    	NULL));
>
>   -    if (hsa != NULL && hsa->i >= 0 && hsa->i < hsa->numTokens) {
>   +    if (hsa != NULL && hsa->i < hsa->numTokens) {
>    	fmt = hsa->format + hsa->i;
>    	if (hsa->hi == NULL) {
>    	    hsa->i++;
>   @@ .
>   patch -p0 <<'@@ .'
>   Index: rpm/rpmdb/header.h
>    
> ====================================================================== 
> ======
>   $ cvs diff -u -r1.65 -r1.66 header.h
>   --- rpm/rpmdb/header.h	14 Nov 2007 21:13:18 -0000	1.65
>   +++ rpm/rpmdb/header.h	15 Nov 2007 23:14:53 -0000	1.66
>   @@ -463,7 +463,7 @@
>     * @return		size of on-disk header
>     */
>    typedef
>   -unsigned int (*HDRsizeof) (/*@null@*/ Header h)
>   +size_t (*HDRsizeof) (/*@null@*/ Header h)
>            /*@modifies h @*/;
>
>    /** \ingroup header
>   @@ -803,7 +803,7 @@
>     * @return		header instance
>     */
>    typedef
>   -int (*HDRgetinstance) (/*@null@*/ Header h)
>   +uint32_t (*HDRgetinstance) (/*@null@*/ Header h)
>    	/*@*/;
>
>    /** \ingroup header
>   @@ -813,7 +813,7 @@
>     * @return		0 always
>     */
>    typedef
>   -int (*HDRsetinstance) (/*@null@*/ Header h, int instance)
>   +uint32_t (*HDRsetinstance) (/*@null@*/ Header h, uint32_t instance)
>    	/*@modifies h @*/;
>
>    /**
>   @@ .
>   patch -p0 <<'@@ .'
>   Index: rpm/rpmdb/header_internal.c
>    
> ====================================================================== 
> ======
>   $ cvs diff -u -r1.15 -r1.16 header_internal.c
>   --- rpm/rpmdb/header_internal.c	15 Nov 2007 14:30:25 -0000	1.15
>   +++ rpm/rpmdb/header_internal.c	15 Nov 2007 23:14:53 -0000	1.16
>   @@ -48,7 +48,8 @@
>    	    info->type = RPM_UINT8_TYPE;
>    	    pe[i].type = (uint32_t) htonl(info->type);
>    	}
>   -	info->offset = ntohl(pe[i].offset);
>   +	info->offset = (int_32) ntohl(pe[i].offset);
>   +assert(negate || info->offset >= 0);	/* XXX insurance */
>    	if (negate)
>    	    info->offset = -info->offset;
>    	info->count = (uint32_t) ntohl(pe[i].count);
>   @@ -57,7 +58,7 @@
>    	    return (int)i;
>    	if (hdrchkAlign(info->type, info->offset))
>    	    return (int)i;
>   -	if (!negate && hdrchkRange(dl, info->offset))
>   +	if (!negate && hdrchkRange((int_32)dl, info->offset))
>    	    return (int)i;
>    	if (hdrchkData(info->count))
>    	    return (int)i;
>   @@ .
>   patch -p0 <<'@@ .'
>   Index: rpm/rpmdb/header_internal.h
>    
> ====================================================================== 
> ======
>   $ cvs diff -u -r1.30 -r1.31 header_internal.h
>   --- rpm/rpmdb/header_internal.h	15 Nov 2007 14:30:25 -0000	1.30
>   +++ rpm/rpmdb/header_internal.h	15 Nov 2007 23:14:53 -0000	1.31
>   @@ -75,7 +75,7 @@
>    /*@owned@*/
>        void * data; 		/*!< Location of tag data. */
>        size_t length;		/*!< No. bytes of data. */
>   -    int rdlen;			/*!< No. bytes of data in region. */
>   +    size_t rdlen;		/*!< No. bytes of data in region. */
>    };
>
>    /** \ingroup header
>   @@ -94,9 +94,9 @@
>        struct rpmop_s h_getops;
>    /*@owned@*/
>        indexEntry index;		/*!< Array of tags. */
>   -    int indexUsed;		/*!< Current size of tag array. */
>   -    int indexAlloced;		/*!< Allocated size of tag array. */
>   -    int flags;
>   +    size_t indexUsed;		/*!< Current size of tag array. */
>   +    size_t indexAlloced;	/*!< Allocated size of tag array. */
>   +    uint32_t flags;
>    #define	HEADERFLAG_SORTED	(1 << 0) /*!< Are header entries  
> sorted? */
>    #define	HEADERFLAG_ALLOCATED	(1 << 1) /*!< Is 1st header region  
> allocated? */
>    #define	HEADERFLAG_LEGACY	(1 << 2) /*!< Header came from legacy  
> source? */
>   @@ .
>   patch -p0 <<'@@ .'
>   Index: rpm/rpmdb/pkgio.c
>    
> ====================================================================== 
> ======
>   $ cvs diff -u -r1.35 -r1.36 pkgio.c
>   --- rpm/rpmdb/pkgio.c	15 Nov 2007 14:30:25 -0000	1.35
>   +++ rpm/rpmdb/pkgio.c	15 Nov 2007 23:14:53 -0000	1.36
>   @@ -153,8 +153,8 @@
>
>        /* Try rpmdb keyring lookup. */
>        if (ts->pkpkt == NULL) {
>   -	int hx = -1;
>   -	int ix = -1;
>   +	unsigned hx = 0xffffffff;
>   +	unsigned ix = 0xffffffff;
>    	rpmdbMatchIterator mi;
>    	Header h;
>
>   @@ -167,18 +167,18 @@
>    	    hx = rpmdbGetIteratorOffset(mi);
>    	    ix = rpmdbGetIteratorFileNum(mi);
>    /*@-moduncon -nullstate @*/
>   -	    if (ix >= he->c
>   +	    if (ix >= (unsigned) he->c
>    	     || b64decode(he->p.argv[ix], (void **) &ts->pkpkt, &ts- 
> >pkpktlen))
>   -		ix = -1;
>   +		ix = 0xffffffff;
>    /*@=moduncon =nullstate @*/
>    	    he->p.ptr = _free(he->p.ptr);
>    	    break;
>    	}
>    	mi = rpmdbFreeIterator(mi);
>
>   -	if (ix >= 0) {
>   +	if (ix < 0xffffffff) {
>    	    char hnum[32];
>   -	    sprintf(hnum, "h#%d", hx);
>   +	    sprintf(hnum, "h#%u", hx);
>    	    pubkeysource = xstrdup(hnum);
>    	} else {
>    	    ts->pkpkt = _free(ts->pkpkt);
>   @@ -490,7 +490,8 @@
>        Header sigh = ptr;
>        static unsigned char zero[8]
>    	= { '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0' };
>   -    int sigSize, pad;
>   +    size_t sigSize;
>   +    size_t pad;
>        rpmRC rc = RPMRC_OK;
>        int xx;
>
>   @@ -504,7 +505,7 @@
>    	if (Fwrite(zero, sizeof(zero[0]), pad, fd) != pad)
>    	    rc = RPMRC_FAIL;
>        }
>   -    rpmlog(RPMLOG_DEBUG, D_("Signature: size(%d)+pad(%d)\n"),  
> sigSize, pad);
>   +    rpmlog(RPMLOG_DEBUG, D_("Signature: size(%u)+pad(%u)\n"),  
> (unsigned)sigSize, (unsigned)pad);
>        return rc;
>    }
>
>   @@ -660,7 +661,8 @@
>        {
>    /*@=sizeoftype@*/
>
>   -	if (entry->info.offset >= dl) {
>   +assert(entry->info.offset > 0);	/* XXX insurance */
>   +	if (entry->info.offset >= (int_32)dl) {
>    	    (void) snprintf(buf, sizeof(buf),
>    		_("region offset: BAD, tag %u type %u offset %d count %u\n"),
>    		(unsigned) entry->info.tag, (unsigned) entry->info.type,
>   @@ -731,7 +733,8 @@
>    	size_t pad = (8 - (sigSize % 8)) % 8; /* 8-byte pad */
>
>    	/* Position at beginning of header. */
>   -	if (pad && (xx = (int) timedRead(fd, (void *)block, pad)) !=  
> (int) pad) {
>   +	if (pad && (xx = (int) timedRead(fd, (void *)block, pad)) !=  
> (int) pad)
>   +	{
>    	    (void) snprintf(buf, sizeof(buf),
>    		_("sigh pad(%u): BAD, read %d bytes\n"), (unsigned) pad, xx);
>    	    goto exit;
>   @@ .
> ______________________________________________________________________
> RPM Package Manager                                    http://rpm5.org
> CVS Sources Repository                                rpm-cvs@rpm5.org
Received on Fri Nov 16 00:27:21 2007
Driven by Jeff Johnson and the RPM project team.
Hosted by OpenPKG and Ralf S. Engelschall.
Powered by FreeBSD and OpenPKG.