[CVS] RPM: rpm-5_4: rpm/rpmdb/ pkgio.c

2017-07-14 Thread Jeff Johnson
  RPM Package Manager, CVS Repository
  http://rpm5.org/cvs/
  

  Server: rpm5.org Name:   Jeff Johnson
  Root:   /v/rpm/cvs   Email:  j...@rpm5.org
  Module: rpm  Date:   14-Jul-2017 13:40:16
  Branch: rpm-5_4  Handle: 2017071411401600

  Modified files:   (Branch: rpm-5_4)
rpm/rpmdb   pkgio.c

  Log:
- use macro __VA_ARGS__

  Summary:
RevisionChanges Path
1.121.2.30  +30 -43 rpm/rpmdb/pkgio.c
  

  patch -p0 <<'@@ .'
  Index: rpm/rpmdb/pkgio.c
  
  $ cvs diff -u -r1.121.2.29 -r1.121.2.30 pkgio.c
  --- rpm/rpmdb/pkgio.c 16 May 2017 20:11:41 -  1.121.2.29
  +++ rpm/rpmdb/pkgio.c 14 Jul 2017 11:40:16 -  1.121.2.30
  @@ -41,7 +41,15 @@
   GENfree(rpmuint32_t *)
   #endif   /* __cplusplus */
   
  -int _pkgio_debug = 0;
  +int _pkgio_debug;
  +#define SPEW(_fmt, ...) \
  +if (_pkgio_debug) \
  + fprintf(stderr, _fmt, __VA_ARGS__)
  +
  +extern int _rpmhkp_debug;
  +#define HKPSPEW(_fmt, ...) \
  +if (_rpmhkp_debug) \
  + fprintf(stderr, _fmt, __VA_ARGS__)
   
   /**
*/
  @@ -64,8 +72,7 @@
   size_t length;
   rpmRC rc = RPMRC_FAIL;   /* assume failure */
   
  -if (_pkgio_debug)
  -fprintf(stderr, "--> rpmWriteHeader(%p, %p, %p)\n", fd, h, msg);
  +SPEW("--> rpmWriteHeader(%p, %p, %p)\n", fd, h, msg);
   
   if (h == NULL) {
if (msg)
  @@ -159,8 +166,7 @@
   int validate = 0;
   int xx;
   
  -if (_rpmhkp_debug)
  -fprintf(stderr, "--> %s(%p,%p)\n", __FUNCTION__, ts, _dig);
  +SPEW("--> %s(%p,%p)\n", __FUNCTION__, ts, _dig);
   
   assert(dig != NULL);
   assert(sigp != NULL);
  @@ -172,8 +178,7 @@
   awol = rpmbfLink(hkp->awol);
   
   #if 0
  -if (_rpmhkp_debug)
  -fprintf(stderr, "==> find sig id %08x %08x ts pubkey id %08x %08x\n",
  +HKPSPEW("==> find sig id %08x %08x ts pubkey id %08x %08x\n",
   pgpGrab(sigp->signid, 4), pgpGrab(sigp->signid+4, 4),
   pgpGrab(hkp->signid, 4), pgpGrab(hkp->signid+4, 4));
   #endif
  @@ -181,8 +186,7 @@
   /* Lazy free of previous pubkey if pubkey does not match this signature. 
*/
   if (memcmp(sigp->signid, hkp->signid, sizeof(hkp->signid))) {
   #if 0
  -if (_rpmhkp_debug)
  -fprintf(stderr, "*** free pkt %p[%d] id %08x %08x\n", hkp->pkt, hkp->pktlen, 
pgpGrab(hkp->signid, 4), pgpGrab(hkp->signid+4, 4));
  +HKPSPEW("*** free pkt %p[%d] id %08x %08x\n", hkp->pkt, hkp->pktlen, 
pgpGrab(hkp->signid, 4), pgpGrab(hkp->signid+4, 4));
   #endif
hkp->pkt = _free(hkp->pkt);
hkp->pktlen = 0;
  @@ -213,8 +217,7 @@
   validate = 0;
break;
}
  -if (_rpmhkp_debug)
  -fprintf(stderr, "\t%s: rpmku  %p[%u]\n", __FUNCTION__, hkp->pkt, (unsigned) 
hkp->pktlen);
  +HKPSPEW("\t%s: rpmku  %p[%u]\n", __FUNCTION__, hkp->pkt, (unsigned) 
hkp->pktlen);
   }
   
   /* Try rpmdb keyring lookup. */
  @@ -265,8 +268,7 @@
hkp->pkt = _free(hkp->pkt);
hkp->pktlen = 0;
}
  -if (_rpmhkp_debug)
  -fprintf(stderr, "\t%s: rpmdb  %p[%u]\n", __FUNCTION__, hkp->pkt, (unsigned) 
hkp->pktlen);
  +HKPSPEW("\t%s: rpmdb  %p[%u]\n", __FUNCTION__, hkp->pkt, (unsigned) 
hkp->pktlen);
   }
   
   /* Try autosign package pubkey (if present). */
  @@ -279,8 +281,7 @@
hkp->pktlen = dig->publen;  dig->publen = 0;
pubkeysource = xstrdup("package");
   validate = -1;   /* XXX rpmhkpValidate is prerequisite for rpmhkpFindKey 
*/
  -if (_rpmhkp_debug)
  -fprintf(stderr, "\t%s: auto   %p[%u]\n", __FUNCTION__, hkp->pkt, (unsigned) 
hkp->pktlen);
  +HKPSPEW("\t%s: auto   %p[%u]\n", __FUNCTION__, hkp->pkt, (unsigned) 
hkp->pktlen);
}
   }
   
  @@ -301,8 +302,7 @@
pubkeysource = xstrdup("keyserver");
   validate = 1;
}
  -if (_rpmhkp_debug)
  -fprintf(stderr, "\t%s: rpmhkp %p[%u]\n", __FUNCTION__, hkp->pkt, (unsigned) 
hkp->pktlen);
  +HKPSPEW("\t%s: rpmhkp %p[%u]\n", __FUNCTION__, hkp->pkt, (unsigned) 
hkp->pktlen);
   }
   
   #ifdef   NOTYET
  @@ -326,8 +326,7 @@
   /* Was a matching pubkey found? */
   if (hkp->pkt == NULL || hkp->pktlen == 0)
goto exit;
  -if (_rpmhkp_debug)
  -fprintf(stderr, "\t%s: match  %p[%u]\n", __FUNCTION__, hkp->pkt, (unsigned) 
hkp->pktlen);
  +HKPSPEW("\t%s: match  %p[%u]\n", __FUNCTION__, hkp->pkt, (unsigned) 
hkp->pktlen);
   
   /* Split the result into packet array. */
   hkp->pkts = _free(hkp->pkts);/* XXX memleaks */
  @@ -353,8 +352,7 @@
case RPMRC_FAIL:/* XXX remap to NOTFOUND? */
case RPMRC_NOTTRUSTED:
default:
  -if (_rpmhkp_debug)
  -fprintf(stderr, "*** rpmhkpValidate: validate %d rc %d\n", validate, rc);
  +HKPSPEW("*** 

[CVS] RPM: rpm-5_4: rpm/rpmdb/ pkgio.c

2016-04-24 Thread Jeff Johnson
  RPM Package Manager, CVS Repository
  http://rpm5.org/cvs/
  

  Server: rpm5.org Name:   Jeff Johnson
  Root:   /v/rpm/cvs   Email:  j...@rpm5.org
  Module: rpm  Date:   24-Apr-2016 19:00:03
  Branch: rpm-5_4  Handle: 2016042417000300

  Modified files:   (Branch: rpm-5_4)
rpm/rpmdb   pkgio.c

  Log:
- fix: verify type/count for RPMSIGTAG_MD5.

  Summary:
RevisionChanges Path
1.121.2.25  +1  -1  rpm/rpmdb/pkgio.c
  

  patch -p0 <<'@@ .'
  Index: rpm/rpmdb/pkgio.c
  
  $ cvs diff -u -r1.121.2.24 -r1.121.2.25 pkgio.c
  --- rpm/rpmdb/pkgio.c 21 Apr 2016 21:28:51 -  1.121.2.24
  +++ rpm/rpmdb/pkgio.c 24 Apr 2016 17:00:03 -  1.121.2.25
  @@ -1034,7 +1034,7 @@
/* All packages should have RPMSIGTAG_SIZE. */
he->tag = (rpmTag) RPMSIGTAG_SIZE;
xx = headerGet(sigh, he, HEADERGET_SIGHEADER);
  - if (xx) {
  + if (xx && he->t == RPM_UINT32_TYPE && he->c == 1) {
/* XXX FIXME: there's an overrun here. */
size_t datasize = he->p.ui32p[0];
he->p.ptr = _free(he->p.ptr);
  @@ .
__
RPM Package Managerhttp://rpm5.org
CVS Sources Repositoryrpm-cvs@rpm5.org


[CVS] RPM: rpm-5_4: rpm/rpmdb/ pkgio.c

2016-04-19 Thread Jeff Johnson
  RPM Package Manager, CVS Repository
  http://rpm5.org/cvs/
  

  Server: rpm5.org Name:   Jeff Johnson
  Root:   /v/rpm/cvs   Email:  j...@rpm5.org
  Module: rpm  Date:   19-Apr-2016 15:11:56
  Branch: rpm-5_4  Handle: 2016041913115600

  Modified files:   (Branch: rpm-5_4)
rpm/rpmdb   pkgio.c

  Log:
- pkgio: better sigh tag checks.

  Summary:
RevisionChanges Path
1.121.2.23  +46 -12 rpm/rpmdb/pkgio.c
  

  patch -p0 <<'@@ .'
  Index: rpm/rpmdb/pkgio.c
  
  $ cvs diff -u -r1.121.2.22 -r1.121.2.23 pkgio.c
  --- rpm/rpmdb/pkgio.c 15 Apr 2016 18:42:14 -  1.121.2.22
  +++ rpm/rpmdb/pkgio.c 19 Apr 2016 13:11:56 -  1.121.2.23
  @@ -779,6 +779,7 @@
   const void * sig = NULL;
   rpmuint32_t siglen = 0;
   pgpPkt pp = (pgpPkt) alloca(sizeof(*pp));
  +rpmuint32_t rtag = 0;/* assume no region tag. */
   
   if (_pkgio_debug)
   fprintf(stderr, "--> rdSignature(%p, %p, %p) dig %p\n", fd, ptr, msg, dig);
  @@ -896,7 +897,17 @@
   
   /* Check (and convert) the 1st tag element. */
   xx = headerVerifyInfo(1, dl, pe, >info, 0);
  -if (xx != -1) {
  +if (xx != -1 ||
  + !(  (entry->info.tag == RPMTAG_HEADERSIGNATURES
  +   && entry->info.type == REGION_TAG_TYPE
  +   && entry->info.offset > 0
  +   && entry->info.count == (rpmTagCount)REGION_TAG_COUNT)
  +  || (entry->info.tag == (rpmTag)RPMSIGTAG_SIZE
  +   && entry->info.type == RPM_UINT32_TYPE
  +   && entry->info.offset == 0
  +   && entry->info.count == (rpmTagCount)1)
  +  ))
  +{
(void) snprintf(buf, sizeof(buf),
_("tag[%d]: BAD, %s"), 0, entryInfoStr(>info));
goto exit;
  @@ -905,6 +916,7 @@
   /* Is there an immutable header region tag? */
   if (entry->info.tag == RPMTAG_HEADERSIGNATURES)
   {
  + rtag = RPMTAG_HEADERSIGNATURES;
/* Is the region tag sane? */
if (!(entry->info.type == REGION_TAG_TYPE
   && entry->info.count == (rpmTagCount)REGION_TAG_COUNT))
  @@ -993,12 +1005,40 @@
goto exit;
}
   
  - /* Print package component sizes. */
  + /* If sigh had a region, then sigh should have a RPMSIGTAG_SHA1. */
  + if (rtag) {
  + he->tag = (rpmTag) RPMSIGTAG_SHA1;
  + xx = headerGet(sigh, he, HEADERGET_SIGHEADER);
  + he->p.ptr = _free(he->p.ptr);
  + if (!xx) {
  + (void) snprintf(buf, sizeof(buf),
  + _("%stag(%u): BAD, missing %s tag"), origin,
  + he->tag, "SHA1");
  + rc = RPMRC_FAIL;
  + goto exit;
  + }
  + }
  +
  + /* All packages should have RPMSIGTAG_MD5. */
  + he->tag = (rpmTag) RPMSIGTAG_MD5;
  + xx = headerGet(sigh, he, HEADERGET_SIGHEADER);
  + if (!xx) {
  + (void) snprintf(buf, sizeof(buf),
  + _("%stag(%u): BAD, missing %s tag"), origin,
  + he->tag, "MD5");
  + he->p.ptr = _free(he->p.ptr);
  + rc = RPMRC_FAIL;
  + goto exit;
  + }
  +
  + /* All packages should have RPMSIGTAG_SIZE. */
he->tag = (rpmTag) RPMSIGTAG_SIZE;
xx = headerGet(sigh, he, HEADERGET_SIGHEADER);
if (xx) {
  + /* XXX FIXME: there's an overrun here. */
size_t datasize = he->p.ui32p[0];
he->p.ptr = _free(he->p.ptr);
  + /* Print package component sizes. */
rc = printSize(fd, sigSize, pad, datasize, st);
if (rc != RPMRC_OK) {
(void) snprintf(buf, sizeof(buf),
  @@ -1008,21 +1048,13 @@
}
} else {
(void) snprintf(buf, sizeof(buf),
  - _("%stag(%u): BAD, missing tag"), origin, he->tag);
  + _("%stag(%u): BAD, missing %s tag"), origin,
  + he->tag, "SIZE");
he->p.ptr = _free(he->p.ptr);
rc = RPMRC_FAIL;
goto exit;
}
   
  - he->tag = (rpmTag) RPMSIGTAG_SHA1;
  - xx = headerGet(sigh, he, HEADERGET_SIGHEADER);
  - he->p.ptr = _free(he->p.ptr);
  - if (!xx) {
  - (void) snprintf(buf, sizeof(buf),
  - _("%stag(%u): BAD, missing tag"), origin, he->tag);
  - rc = RPMRC_FAIL;
  - goto exit;
  - }
   }
   (void) headerSetStartOff(sigh, (rpmuint32_t)startoff);
   (void) headerSetEndOff(sigh, fd->stats->ops[FDSTAT_READ].bytes);
  @@ -1277,7 +1309,9 @@
char *b, size_t nb)
   {
   rpmuint32_t * ei = (rpmuint32_t *) uh;
  +#ifdef   UNUSED
   rpmuint32_t il = (rpmuint32_t) ntohl(ei[0]);
  +#endif
  

[CVS] RPM: rpm-5_4: rpm/rpmdb/ pkgio.c

2016-04-11 Thread Jeff Johnson
  RPM Package Manager, CVS Repository
  http://rpm5.org/cvs/
  

  Server: rpm5.org Name:   Jeff Johnson
  Root:   /v/rpm/cvs   Email:  j...@rpm5.org
  Module: rpm  Date:   11-Apr-2016 09:00:16
  Branch: rpm-5_4  Handle: 2016041107001600

  Modified files:   (Branch: rpm-5_4)
rpm/rpmdb   pkgio.c

  Log:
- pkgio: remove splint annotations, consolidate xar handling code.

  Summary:
RevisionChanges Path
1.121.2.20  +63 -141rpm/rpmdb/pkgio.c
  

  patch -p0 <<'@@ .'
  Index: rpm/rpmdb/pkgio.c
  
  $ cvs diff -u -r1.121.2.19 -r1.121.2.20 pkgio.c
  --- rpm/rpmdb/pkgio.c 10 Apr 2016 22:03:54 -  1.121.2.19
  +++ rpm/rpmdb/pkgio.c 11 Apr 2016 07:00:16 -  1.121.2.20
  @@ -35,33 +35,18 @@
   #include "signature.h"
   #include "debug.h"
   
  -/*@access rpmts @*/
  -/*@access rpmxar @*/
  -/*@access pgpDig @*/
  -/*@access pgpDigParams @*/
  -/*@access Header @*//* XXX compared with NULL */
  -/*@access entryInfo @*/
  -/*@access indexEntry @*/
  -/*@access FD_t @*/   /* XXX stealing digests */
  -/*@access FDSTAT_t @*/   /* XXX stealing digests */
  -
   #ifdef __cplusplus
   GENfree(struct rpmlead *)
   GENfree(rpmuint8_t **)
   GENfree(rpmuint32_t *)
   #endif   /* __cplusplus */
   
  -/*@unchecked@*/
   int _pkgio_debug = 0;
   
   /**
*/
  -/*@-exportheader@*/
  -/*@unused@*/ ssize_t timedRead(FD_t fd, /*@out@*/ void * bufptr, size_t 
length)
  - /*@globals fileSystem @*/
  - /*@modifies fd, *bufptr, fileSystem @*/;
  +ssize_t timedRead(FD_t fd, /*@out@*/ void * bufptr, size_t length);
   #define  timedRead   (ufdio->read)
  -/*@=exportheader@*/
   
   /*===*/
   /** \ingroup header
  @@ -73,8 +58,6 @@
*/
   static
   rpmRC rpmWriteHeader(FD_t fd, /*@null@*/ Header h, /*@null@*/ const char ** 
msg)
  - /*@globals fileSystem, internalState @*/
  - /*@modifies fd, h, *msg, fileSystem, internalState @*/
   {
   const void * uh = NULL;
   size_t nb;
  @@ -111,9 +94,7 @@
}
   }
   
  -/*@-sizeoftype@*/
   nb = Fwrite(uh, sizeof(char), length, fd);
  -/*@=sizeoftype@*/
   if (nb != length || Ferror(fd)) {
if (msg)
*msg = (nb > 0
  @@ -136,16 +117,12 @@
   
   if (ts != NULL && (int)opx >= 0 && (int)opx < RPMTS_OP_MAX)
op = ts->ops + opx;
  -/*@-usereleased -compdef @*/
   return op;
  -/*@=usereleased =compdef @*/
   }
   
   pgpDigParams rpmtsPubkey(const rpmts ts)
   {
  -/*@-onlytrans@*/
   return pgpGetPubkey(rpmtsDig(ts));
  -/*@=onlytrans@*/
   }
   
   rpmdb rpmtsGetRdb(rpmts ts)
  @@ -154,9 +131,7 @@
   if (ts != NULL) {
rdb = ts->rdb;
   }
  -/*@-compdef -refcounttrans -usereleased @*/
   return rdb;
  -/*@=compdef =refcounttrans =usereleased @*/
   }
   
   rpmRC rpmtsFindPubkey(rpmts ts, void * _dig)
  @@ -181,9 +156,7 @@
   assert(dig != NULL);
   assert(sigp != NULL);
   assert(pubp != NULL);
  -/*@-sefparams@*/
   assert(rpmtsDig(ts) == dig);
  -/*@=sefparams@*/
   if (ts->hkp == NULL)
ts->hkp = rpmhkpNew(NULL, 0);
   hkp = rpmhkpLink(ts->hkp);
  @@ -254,9 +227,7 @@
   
/* Retrieve the pubkey that matches the signature. */
he->tag = RPMTAG_PUBKEYS;
  -/*@-nullstate@*/
mi = rpmmiInit(rpmtsGetRdb(ts), RPMTAG_PUBKEYS, sigp->signid, 
sizeof(sigp->signid));
  -/*@=nullstate@*/
while ((h = rpmmiNext(mi)) != NULL) {
if (!headerGet(h, he, 0))
continue;
  @@ -433,24 +404,16 @@
   if (_rpmhkp_debug)
   fprintf(stderr, "<-- %s(%p,%p) res %d\n", __FUNCTION__, ts, _dig, res);
   
  -/*@-nullstate@*/
   return res;
  -/*@=nullstate@*/
   }
   
   pgpDig rpmtsDig(rpmts ts)
   {
  -/*@-mods@*/ /* FIX: hide lazy malloc for now */
   if (ts->dig == NULL) {
ts->dig = pgpDigNew(RPMVSF_DEFAULT, (pgpPubkeyAlgo)0);
  -/*@-refcounttrans@*/
(void) pgpSetFindPubkey(ts->dig, (int (*)(void *, void 
*))rpmtsFindPubkey, ts);
  -/*@=refcounttrans@*/
   }
  -/*@=mods@*/
  -/*@-compdef -retexpose -usereleased@*/
   return ts->dig;
  -/*@=compdef =retexpose =usereleased@*/
   }
   
   void rpmtsCleanDig(rpmts ts)
  @@ -461,10 +424,8 @@
(void) rpmswAdd(rpmtsOp(ts, opx), (rpmop)pgpStatsAccumulator(ts->dig, 
opx));
opx = RPMTS_OP_SIGNATURE;
(void) rpmswAdd(rpmtsOp(ts, opx), (rpmop)pgpStatsAccumulator(ts->dig, 
opx));
  -/*@-onlytrans@*/
(void) pgpDigFree(ts->dig);
ts->dig = NULL; /* XXX make sure the ptr is __REALLY__ gone */
  -/*@=onlytrans@*/
   }
   }
   
  @@ -485,16 +446,12 @@
   char 

[CVS] RPM: rpm-5_4: rpm/rpmdb/ pkgio.c

2016-04-03 Thread Jeff Johnson
  RPM Package Manager, CVS Repository
  http://rpm5.org/cvs/
  

  Server: rpm5.org Name:   Jeff Johnson
  Root:   /v/rpm/cvs   Email:  j...@rpm5.org
  Module: rpm  Date:   04-Apr-2016 06:21:40
  Branch: rpm-5_4  Handle: 2016040404214000

  Modified files:   (Branch: rpm-5_4)
rpm/rpmdb   pkgio.c

  Log:
- pkgio: fix: can't retrofit a trailer tag fix with PROT_READ in place.
- pkgio: improved santy checks for {il,dl} based on file size.

  Summary:
RevisionChanges Path
1.121.2.18  +82 -22 rpm/rpmdb/pkgio.c
  

  patch -p0 <<'@@ .'
  Index: rpm/rpmdb/pkgio.c
  
  $ cvs diff -u -r1.121.2.17 -r1.121.2.18 pkgio.c
  --- rpm/rpmdb/pkgio.c 2 Apr 2016 23:01:12 -   1.121.2.17
  +++ rpm/rpmdb/pkgio.c 4 Apr 2016 04:21:40 -   1.121.2.18
  @@ -706,16 +706,20 @@
* @param siglen signature header size
* @param padsignature padding
* @param datalenlength of header+payload
  + * @retval *st   stat(2) of input file
* @return   rpmRC return code
*/
  -static inline rpmRC printSize(FD_t fd, size_t siglen, size_t pad, size_t 
datalen)
  +static inline rpmRC printSize(FD_t fd, size_t siglen, size_t pad,
  + size_t datalen, struct stat *st)
/*@globals fileSystem, internalState @*/
/*@modifies fileSystem, internalState @*/
   {
  -struct stat sb, * st = 
   size_t expected;
   size_t nl = rpmpkgSizeof("Lead", NULL);
   
  +if (st == NULL)
  + st = memset(alloca(sizeof(*st)), 0, sizeof(*st));
  +
   #ifndef  DYING   /* XXX Fstat(2) contentLength not gud enuf yet. */
   int fdno = Fileno(fd);
   /* HACK: workaround for davRead wiring. */
  @@ -775,6 +779,7 @@
   rpmRC rc = RPMRC_FAIL;   /* assume failure */
   int xx;
   rpmuint32_t i;
  +struct stat sb, *st = 
   static int map = 1;
   
   if (_pkgio_debug)
  @@ -794,6 +799,13 @@
goto exit;
}
   }
  +
  +if (Fstat(fd, st) < 0) {
  + (void) snprintf(buf, sizeof(buf),
  + _("sigh stat: BAD, Fstat(2) failed"));
  + goto exit;
  +}
  +
   startoff = fd->stats->ops[FDSTAT_READ].bytes;
   if ((xx = (int) timedRead(fd, (char *)block, sizeof(block))) != (int) 
sizeof(block)) {
(void) snprintf(buf, sizeof(buf),
  @@ -814,22 +826,28 @@
goto exit;
}
   }
  +/* XXX arbitrary limit check doesn't help much */
   il = (rpmuint32_t) ntohl(block[2]);
  -if (il > 32) {
  +if (il > (st->st_size - startoff - sizeof(block)) || il > 32) {
(void) snprintf(buf, sizeof(buf),
_("sigh tags: BAD, no. of tags(%u) out of range"), (unsigned) 
il);
goto exit;
   }
  +/* XXX arbitrary limit check doesn't help much */
   dl = (rpmuint32_t) ntohl(block[3]);
  -if (dl > 8192) {
  +if (dl > (st->st_size - startoff - sizeof(block)) || dl > 8192) {
(void) snprintf(buf, sizeof(buf),
_("sigh data: BAD, no. of bytes(%u) out of range"), (unsigned) 
dl);
goto exit;
   }
   
  -/*@-sizeoftype@*/
   nb = (il * sizeof(struct entryInfo_s)) + dl;
  -/*@=sizeoftype@*/
  +if (nb > (st->st_size - startoff - sizeof(block))) {
  + (void) snprintf(buf, sizeof(buf),
  + _("hdr blob: BAD, header size (%u) larger than file size"),
  + (unsigned) nb);
  +   goto exit;
  +}
   if (map) {
size_t pvlen = (sizeof(il) + sizeof(dl) + nb);
   static const int prot = PROT_READ | PROT_WRITE;
  @@ -844,7 +862,8 @@
   "==> mmap(%p[%u], 0x%x, 0x%x, %d, 0x%x) error(%d): %s\n",
   NULL, (unsigned)pvlen, prot, flags, fdno, (unsigned)off,
   errno, strerror(errno));
  -} else {
  +} else
  +{
size_t pvlen = (sizeof(il) + sizeof(dl) + nb);
ei = (rpmuint32_t *) xmalloc(pvlen);
   }
  @@ -915,7 +934,9 @@
if (info->tag == (rpmuint32_t) htonl(RPMTAG_HEADERIMAGE)) {
rpmuint32_t stag = (rpmuint32_t) htonl(RPMTAG_HEADERSIGNATURES);
info->tag = (rpmTag) stag;
  +#ifdef   DYING   /* XXX can't retrofit with PROT_READ */
memcpy(dataEnd, , sizeof(stag));
  +#endif
}
dataEnd += REGION_TAG_COUNT;
   
  @@ -986,7 +1007,7 @@
xx = headerGet(sigh, he, HEADERGET_SIGHEADER);
if (xx) {
size_t datasize = he->p.ui32p[0];
  - rc = printSize(fd, sigSize, pad, datasize);
  + rc = printSize(fd, sigSize, pad, datasize, st);
if (rc != RPMRC_OK)

[CVS] RPM: rpm-5_4: rpm/rpmdb/ pkgio.c

2014-05-15 Thread Pinto Elia
  RPM Package Manager, CVS Repository
  http://rpm5.org/cvs/
  

  Server: rpm5.org Name:   Pinto Elia
  Root:   /v/rpm/cvs   Email:  devzero2...@rpm5.org
  Module: rpm  Date:   15-May-2014 10:50:11
  Branch: rpm-5_4  Handle: 2014051508501000

  Modified files:   (Branch: rpm-5_4)
rpm/rpmdb   pkgio.c

  Log:
rpmdb/pkgio.c: typofix

Fix the typos introduced in the patches for

- coverity #1214082 (rev. 1.121.2.9)
- coverity #124081  (rev. 1.121.2.8)

  Summary:
RevisionChanges Path
1.121.2.10  +2  -2  rpm/rpmdb/pkgio.c
  

  patch -p0 '@@ .'
  Index: rpm/rpmdb/pkgio.c
  
  $ cvs diff -u -r1.121.2.9 -r1.121.2.10 pkgio.c
  --- rpm/rpmdb/pkgio.c 14 May 2014 23:09:05 -  1.121.2.9
  +++ rpm/rpmdb/pkgio.c 15 May 2014 08:50:10 -  1.121.2.10
  @@ -837,7 +837,7 @@
   static const off_t off = 0;
   
ei = (rpmuint32_t *) mmap(NULL, pvlen, prot, flags, fdno, off);
  -assert(ei != NULL 77 ei != (void *)-1);  /* coverity #1214082 */
  +assert(ei != NULL  ei != (void *)-1);  /* coverity #1214082 */
if (ei == NULL || ei == (void *)-1)
   fprintf(stderr,
   == mmap(%p[%u], 0x%x, 0x%x, %d, 0x%x) error(%d): %s\n,
  @@ -1513,7 +1513,7 @@
   static const off_t off = 0;
   
ei = (rpmuint32_t *) mmap(NULL, uc, prot, flags, fdno, off);
  -assert(ei != NULL 77 ei != (void *)-1);  /* coverity #124081 */
  +assert(ei != NULL  ei != (void *)-1);  /* coverity #124081 */
if (ei == NULL || ei == (void *)-1)
   fprintf(stderr,
   == mmap(%p[%u], 0x%x, 0x%x, %d, 0x%x) error(%d): %s\n,
  @@ .
__
RPM Package Managerhttp://rpm5.org
CVS Sources Repositoryrpm-cvs@rpm5.org


[CVS] RPM: rpm-5_4: rpm/rpmdb/ pkgio.c

2014-05-14 Thread Jeff Johnson
  RPM Package Manager, CVS Repository
  http://rpm5.org/cvs/
  

  Server: rpm5.org Name:   Jeff Johnson
  Root:   /v/rpm/cvs   Email:  j...@rpm5.org
  Module: rpm  Date:   15-May-2014 01:07:20
  Branch: rpm-5_4  Handle: 2014051423071800

  Modified files:   (Branch: rpm-5_4)
rpm/rpmdb   pkgio.c

  Log:
- coverity #124081.

  Summary:
RevisionChanges Path
1.121.2.8   +1  -0  rpm/rpmdb/pkgio.c
  

  patch -p0 '@@ .'
  Index: rpm/rpmdb/pkgio.c
  
  $ cvs diff -u -r1.121.2.7 -r1.121.2.8 pkgio.c
  --- rpm/rpmdb/pkgio.c 5 May 2014 19:44:11 -   1.121.2.7
  +++ rpm/rpmdb/pkgio.c 14 May 2014 23:07:18 -  1.121.2.8
  @@ -1512,6 +1512,7 @@
   static const off_t off = 0;
   
ei = (rpmuint32_t *) mmap(NULL, uc, prot, flags, fdno, off);
  +assert(ei != NULL 77 ei != (void *)-1);  /* coverity #124081 */
if (ei == NULL || ei == (void *)-1)
   fprintf(stderr,
   == mmap(%p[%u], 0x%x, 0x%x, %d, 0x%x) error(%d): %s\n,
  @@ .
__
RPM Package Managerhttp://rpm5.org
CVS Sources Repositoryrpm-cvs@rpm5.org


[CVS] RPM: rpm-5_4: rpm/rpmdb/ pkgio.c

2014-05-14 Thread Jeff Johnson
  RPM Package Manager, CVS Repository
  http://rpm5.org/cvs/
  

  Server: rpm5.org Name:   Jeff Johnson
  Root:   /v/rpm/cvs   Email:  j...@rpm5.org
  Module: rpm  Date:   15-May-2014 01:09:08
  Branch: rpm-5_4  Handle: 2014051423090500

  Modified files:   (Branch: rpm-5_4)
rpm/rpmdb   pkgio.c

  Log:
- coverity #1214082.

  Summary:
RevisionChanges Path
1.121.2.9   +1  -0  rpm/rpmdb/pkgio.c
  

  patch -p0 '@@ .'
  Index: rpm/rpmdb/pkgio.c
  
  $ cvs diff -u -r1.121.2.8 -r1.121.2.9 pkgio.c
  --- rpm/rpmdb/pkgio.c 14 May 2014 23:07:18 -  1.121.2.8
  +++ rpm/rpmdb/pkgio.c 14 May 2014 23:09:05 -  1.121.2.9
  @@ -837,6 +837,7 @@
   static const off_t off = 0;
   
ei = (rpmuint32_t *) mmap(NULL, pvlen, prot, flags, fdno, off);
  +assert(ei != NULL 77 ei != (void *)-1);  /* coverity #1214082 */
if (ei == NULL || ei == (void *)-1)
   fprintf(stderr,
   == mmap(%p[%u], 0x%x, 0x%x, %d, 0x%x) error(%d): %s\n,
  @@ .
__
RPM Package Managerhttp://rpm5.org
CVS Sources Repositoryrpm-cvs@rpm5.org