diff options
author | jbj <devnull@localhost> | 2002-09-17 15:21:03 +0000 |
---|---|---|
committer | jbj <devnull@localhost> | 2002-09-17 15:21:03 +0000 |
commit | 0ef682d77e28d4ab69e11b4c064acb195e061737 (patch) | |
tree | 63c4b804ad80e9c8663ce8d32057b8fec1fbe304 | |
parent | c1542ea2071d8c4086877587919eb7e4165c2b85 (diff) | |
download | librpm-tizen-0ef682d77e28d4ab69e11b4c064acb195e061737.tar.gz librpm-tizen-0ef682d77e28d4ab69e11b4c064acb195e061737.tar.bz2 librpm-tizen-0ef682d77e28d4ab69e11b4c064acb195e061737.zip |
- lclint clean.
CVS patchset: 5715
CVS date: 2002/09/17 15:21:03
-rw-r--r-- | CHANGES | 1 | ||||
-rw-r--r-- | lib/package.c | 66 | ||||
-rw-r--r-- | lib/psm.c | 17 | ||||
-rw-r--r-- | lib/query.c | 2 | ||||
-rw-r--r-- | lib/rpmcli.h | 7 | ||||
-rw-r--r-- | lib/rpmlib.h | 18 | ||||
-rw-r--r-- | lib/signature.c | 45 | ||||
-rw-r--r-- | lib/signature.h | 4 | ||||
-rw-r--r-- | rpmdb/fprint.h | 5 | ||||
-rw-r--r-- | rpmdb/header.c | 10 | ||||
-rw-r--r-- | rpmdb/legacy.c | 5 | ||||
-rw-r--r-- | rpmdb/rpmdb.c | 20 | ||||
-rw-r--r-- | rpmdb/rpmdb.h | 24 | ||||
-rw-r--r-- | rpmio/macro.c | 6 | ||||
-rw-r--r-- | rpmio/rpmrpc.c | 5 |
15 files changed, 154 insertions, 81 deletions
@@ -291,6 +291,7 @@ - fix: parse header data more carefully. - fix: register SIGCHLD handler before forking (#73134). - better diagnostics on failed header parsing. + - lclint clean. 4.0.3 -> 4.0.4: - solaris: translate i86pc to i386 (#57182). diff --git a/lib/package.c b/lib/package.c index 984981fcd..6b1c96ede 100644 --- a/lib/package.c +++ b/lib/package.c @@ -241,8 +241,8 @@ Header headerRegenSigHeader(const Header h, int noArchiveSize) * @return 0 if new keyid, otherwise 1 */ static int rpmtsStashKeyid(rpmts ts) - /*@globals nkeyids, keyids @*/ - /*@modifies nkeyids, keyids @*/ + /*@globals nextkeyid, nkeyids, keyids @*/ + /*@modifies nextkeyid, nkeyids, keyids @*/ { const void * sig = rpmtsSig(ts); pgpDig dig = rpmtsDig(ts); @@ -270,7 +270,8 @@ static int rpmtsStashKeyid(rpmts ts) keyids = xrealloc(keyids, nkeyids * sizeof(*keyids)); } /*@-boundswrite@*/ - keyids[nextkeyid] = keyid; + if (keyids) /* XXX can't happen */ + keyids[nextkeyid] = keyid; /*@=boundswrite@*/ nextkeyid++; nextkeyid %= nkeyids_max; @@ -280,7 +281,9 @@ static int rpmtsStashKeyid(rpmts ts) int headerVerifyInfo(int il, int dl, const void * pev, void * iv, int negate) { +/*@-castexpose@*/ entryInfo pe = (entryInfo) pev; +/*@=castexpose@*/ entryInfo info = iv; int i; @@ -349,11 +352,13 @@ rpmRC headerCheck(rpmts ts, const void * uh, size_t uc, const char ** msg) int xx; int i; +/*@-boundswrite@*/ buf[0] = '\0'; +/*@=boundswrite@*/ /* Is the blob the right size? */ if (uc > 0 && pvlen != uc) { - snprintf(buf, sizeof(buf), + (void) snprintf(buf, sizeof(buf), _("blob size(%d): BAD, 8 + 16 * il(%d) + dl(%d)\n"), uc, il, dl); goto exit; @@ -362,7 +367,7 @@ rpmRC headerCheck(rpmts ts, const void * uh, size_t uc, const char ** msg) /* Check (and convert) the 1st tag element. */ xx = headerVerifyInfo(1, dl, pe, &entry->info, 0); if (xx != -1) { - snprintf(buf, sizeof(buf), + (void) snprintf(buf, sizeof(buf), _("tag[%d]: BAD, tag %d type %d offset %d count %d\n"), 0, entry->info.tag, entry->info.type, entry->info.offset, entry->info.count); @@ -382,7 +387,7 @@ rpmRC headerCheck(rpmts ts, const void * uh, size_t uc, const char ** msg) /* Is the offset within the data area? */ if (entry->info.offset >= dl) { - snprintf(buf, sizeof(buf), + (void) snprintf(buf, sizeof(buf), _("region offset: BAD, tag %d type %d offset %d count %d\n"), entry->info.tag, entry->info.type, entry->info.offset, entry->info.count); @@ -391,19 +396,19 @@ rpmRC headerCheck(rpmts ts, const void * uh, size_t uc, const char ** msg) /* Is there an immutable header region tag trailer? */ regionEnd = dataStart + entry->info.offset; +/*@-sizeoftype@*/ /*@-bounds@*/ (void) memcpy(info, regionEnd, REGION_TAG_COUNT); /*@=bounds@*/ regionEnd += REGION_TAG_COUNT; -/*@-sizeoftype@*/ xx = headerVerifyInfo(1, dl, info, &entry->info, 1); if (xx != -1 || !(entry->info.tag == RPMTAG_HEADERIMMUTABLE && entry->info.type == RPM_BIN_TYPE && entry->info.count == REGION_TAG_COUNT)) { - snprintf(buf, sizeof(buf), + (void) snprintf(buf, sizeof(buf), _("region trailer: BAD, tag %d type %d offset %d count %d\n"), entry->info.tag, entry->info.type, entry->info.offset, entry->info.count); @@ -417,7 +422,7 @@ rpmRC headerCheck(rpmts ts, const void * uh, size_t uc, const char ** msg) /* Is the no. of tags in the region less than the total no. of tags? */ ril = entry->info.offset/sizeof(*pe); if ((entry->info.offset % sizeof(*pe)) || ril > il) { - snprintf(buf, sizeof(buf), + (void) snprintf(buf, sizeof(buf), _("region size: BAD, ril(%d) > il(%d)\n"), ril, il); goto exit; } @@ -426,7 +431,7 @@ rpmRC headerCheck(rpmts ts, const void * uh, size_t uc, const char ** msg) for (i = ril; i < il; i++) { xx = headerVerifyInfo(1, dl, pe+i, &entry->info, 0); if (xx != -1) { - snprintf(buf, sizeof(buf), + (void) snprintf(buf, sizeof(buf), _("tag[%d]: BAD, tag %d type %d offset %d count %d\n"), i, entry->info.tag, entry->info.type, entry->info.offset, entry->info.count); @@ -446,7 +451,7 @@ rpmRC headerCheck(rpmts ts, const void * uh, size_t uc, const char ** msg) } if (entry->info.type != RPM_STRING_TYPE || *b != '\0' || blen != 40) { - snprintf(buf, sizeof(buf), _("hdr SHA1: BAD, not hex\n")); + (void) snprintf(buf, sizeof(buf), _("hdr SHA1: BAD, not hex\n")); goto exit; } /*@=boundsread@*/ @@ -464,7 +469,7 @@ rpmRC headerCheck(rpmts ts, const void * uh, size_t uc, const char ** msg) if (vsflags & RPMVSF_NODSAHEADER) /*@switchbreak@*/ break; if (entry->info.type != RPM_BIN_TYPE) { - snprintf(buf, sizeof(buf), _("hdr DSA: BAD, not binary\n")); + (void) snprintf(buf, sizeof(buf), _("hdr DSA: BAD, not binary\n")); goto exit; } /*@-boundswrite@*/ @@ -481,8 +486,10 @@ rpmRC headerCheck(rpmts ts, const void * uh, size_t uc, const char ** msg) exit: /* Return determined RPMRC_OK/RPMRC_FAIL conditions. */ if (rc != RPMRC_NOTFOUND) { +/*@-boundswrite@*/ buf[sizeof(buf)-1] = '\0'; if (msg) *msg = xstrdup(buf); +/*@=boundswrite@*/ return rc; } @@ -491,17 +498,19 @@ exit: verifyinfo_exit: xx = headerVerifyInfo(ril-1, dl, pe+1, &entry->info, 0); if (xx != -1) { - snprintf(buf, sizeof(buf), + (void) snprintf(buf, sizeof(buf), _("tag[%d]: BAD, tag %d type %d offset %d count %d\n"), xx+1, entry->info.tag, entry->info.type, entry->info.offset, entry->info.count); rc = RPMRC_FAIL; } else { - snprintf(buf, sizeof(buf), "Header sanity check: OK\n"); + (void) snprintf(buf, sizeof(buf), "Header sanity check: OK\n"); rc = RPMRC_OK; } +/*@-boundswrite@*/ buf[sizeof(buf)-1] = '\0'; if (msg) *msg = xstrdup(buf); +/*@=boundswrite@*/ return rc; } @@ -631,46 +640,57 @@ rpmRC rpmReadHeader(rpmts ts, FD_t fd, Header *hdrp, const char ** msg) rpmRC rc = RPMRC_FAIL; /* assume failure */ int xx; +/*@-boundswrite@*/ buf[0] = '\0'; if (hdrp) *hdrp = NULL; if (msg) *msg = NULL; +/*@=boundswrite@*/ + memset(block, 0, sizeof(block)); if ((xx = timedRead(fd, (char *)block, sizeof(block))) != sizeof(block)) { - snprintf(buf, sizeof(buf), + (void) snprintf(buf, sizeof(buf), _("hdr size(%d): BAD, read returned %d\n"), sizeof(block), xx); goto exit; } if (memcmp(block, header_magic, sizeof(header_magic))) { - snprintf(buf, sizeof(buf), _("hdr magic: BAD\n")); + (void) snprintf(buf, sizeof(buf), _("hdr magic: BAD\n")); goto exit; } +/*@-boundsread@*/ il = ntohl(block[2]); +/*@=boundsread@*/ if (hdrchkTags(il)) { - snprintf(buf, sizeof(buf), + (void) snprintf(buf, sizeof(buf), _("hdr tags: BAD, no. of tags(%d) out of range\n"), il); goto exit; } +/*@-boundsread@*/ dl = ntohl(block[3]); +/*@=boundsread@*/ if (hdrchkData(dl)) { - snprintf(buf, sizeof(buf), + (void) snprintf(buf, sizeof(buf), _("hdr data: BAD, no. of bytes(%d) out of range\n"), dl); goto exit; } +/*@-sizeoftype@*/ nb = (il * sizeof(struct entryInfo_s)) + dl; +/*@=sizeoftype@*/ uc = sizeof(il) + sizeof(dl) + nb; ei = xmalloc(uc); +/*@-bounds@*/ ei[0] = block[2]; ei[1] = block[3]; if ((xx = timedRead(fd, (char *)&ei[2], nb)) != nb) { - snprintf(buf, sizeof(buf), + (void) snprintf(buf, sizeof(buf), _("hdr blob(%d): BAD, read returned %d\n"), nb, xx); goto exit; } +/*@=bounds@*/ /* Sanity check header tags */ rc = headerCheck(ts, ei, uc, msg); @@ -680,15 +700,17 @@ rpmRC rpmReadHeader(rpmts ts, FD_t fd, Header *hdrp, const char ** msg) /* OK, blob looks sane, load the header. */ h = headerLoad(ei); if (h == NULL) { - snprintf(buf, sizeof(buf), _("hdr load: BAD\n")); + (void) snprintf(buf, sizeof(buf), _("hdr load: BAD\n")); goto exit; } h->flags |= HEADERFLAG_ALLOCATED; ei = NULL; /* XXX will be freed with header */ exit: - if (rc == RPMRC_OK && hdrp && h) +/*@-boundswrite@*/ + if (hdrp && h && rc == RPMRC_OK) *hdrp = headerLink(h); +/*@=boundswrite@*/ ei = _free(ei); h = headerFree(h); @@ -702,6 +724,7 @@ exit: return rc; } +/*@-bounds@*/ /* LCL: segfault */ int rpmReadPackageFile(rpmts ts, FD_t fd, const char * fn, Header * hdrp) { pgpDig dig; @@ -987,3 +1010,4 @@ exit: sigh = rpmFreeSignature(sigh); return rc; } +/*@=bounds@*/ @@ -785,7 +785,7 @@ fprintf(stderr, " Disable: %p[0:%d:%d] active %d\n", psmtbl.psms, psmtbl.npsms */ static pid_t psmFork(rpmpsm psm) /*@globals fileSystem, internalState @*/ - /*@modifies psm, fileSystem, internalState @*/ + /*@modifies fileSystem, internalState @*/ { pid_t pid; @@ -804,8 +804,8 @@ fprintf(stderr, " Fork: %p[%d:%d:%d] = %p child %d\n", psmtbl.psms, 0, psmt * @return fork(2) pid */ static pid_t psmRegisterFork(rpmpsm psm) - /*@globals psmtbl, fileSystem @*/ - /*@modifies psm, psmtbl, fileSystem @*/ + /*@globals psmtbl, fileSystem, internalState @*/ + /*@modifies psm, psmtbl, fileSystem, internalState @*/ { sigset_t newMask, oldMask; int empty = -1; @@ -850,8 +850,8 @@ fprintf(stderr, " Register: %p[%d:%d:%d] = %p\n", psmtbl.psms, empty, psmtbl.np * Unregister a child reaper. */ static int psmUnregister(rpmpsm psm, pid_t child) - /*@globals psmtbl, fileSystem @*/ - /*@modifies psmtbl, fileSystem @*/ + /*@globals psmtbl, fileSystem, internalState @*/ + /*@modifies psmtbl, fileSystem, internalState @*/ { sigset_t newMask, oldMask; int i = 0; @@ -895,6 +895,8 @@ fprintf(stderr, "Unregister: %p[%d:%d:%d] = %p child %d\n", psmtbl.psms, i, psmt * @return */ static inline pid_t psmGetReaped(rpmpsm psm) + /*@globals fileSystem @*/ + /*@modifies fileSystem @*/ { sigset_t newMask, oldMask; pid_t reaped; @@ -992,6 +994,7 @@ static rpmRC runScript(rpmpsm psm, Header h, const char * sln, FD_t out; rpmRC rc = RPMRC_OK; const char *n, *v, *r; + pid_t pid; if (progArgv == NULL && script == NULL) return rc; @@ -1113,7 +1116,9 @@ static rpmRC runScript(rpmpsm psm, Header h, const char * sln, if (out == NULL) return RPMRC_FAIL; /* XXX can't happen */ /*@-branchstate@*/ - if ((psm->child = psmRegisterFork(psm)) == 0) { + pid = psmRegisterFork(psm); + psm->child = pid; + if (psm->child == 0) { const char * rootDir; int pipes[2]; diff --git a/lib/query.c b/lib/query.c index 939b5c9c5..c13def9cc 100644 --- a/lib/query.c +++ b/lib/query.c @@ -312,6 +312,7 @@ int showQueryPackage(QVA_t qva, /*@unused@*/ rpmts ts, Header h) _("package has neither file owner or id lists\n")); } } +/*@-branchstate@*/ if (te > t) { /*@-boundswrite@*/ *te++ = '\n'; @@ -321,6 +322,7 @@ int showQueryPackage(QVA_t qva, /*@unused@*/ rpmts ts, Header h) *t = '\0'; /*@=boundswrite@*/ } +/*@=branchstate@*/ } rc = 0; diff --git a/lib/rpmcli.h b/lib/rpmcli.h index b66ff41fd..47cd2b1bc 100644 --- a/lib/rpmcli.h +++ b/lib/rpmcli.h @@ -299,8 +299,8 @@ extern struct poptOption rpmVerifyPoptTable[]; * @return result of last non-zero showPackage() return */ int rpmcliShowMatches(QVA_t qva, rpmts ts) - /*@globals rpmGlobalMacroContext, fileSystem@*/ - /*@modifies qva, rpmGlobalMacroContext, fileSystem @*/; + /*@globals rpmGlobalMacroContext, fileSystem, internalState @*/ + /*@modifies qva, rpmGlobalMacroContext, fileSystem, internalState @*/; /** \ingroup rpmcli * Display list of tags that can be used in --queryformat. @@ -560,7 +560,8 @@ int rpmInstall(rpmts ts, struct rpmInstallArguments_s * ia, int rpmErase(rpmts ts, const struct rpmInstallArguments_s * ia, /*@null@*/ const char ** argv) /*@globals rpmGlobalMacroContext, fileSystem, internalState @*/ - /*@modifies ts, rpmGlobalMacroContext, fileSystem, internalState @*/; + /*@modifies ts, ia, rpmGlobalMacroContext, + fileSystem, internalState @*/; /** * A rollback transaction id element. diff --git a/lib/rpmlib.h b/lib/rpmlib.h index 72e2e4218..89611ee1e 100644 --- a/lib/rpmlib.h +++ b/lib/rpmlib.h @@ -123,10 +123,10 @@ int headerNVR(Header h, * Translate and merge legacy signature tags into header. * @todo Remove headerSort() through headerInitIterator() modifies sig. * @param h header - * @param sig signature header + * @param sigh signature header */ -void headerMergeLegacySigs(Header h, const Header sig) - /*@modifies h, sig @*/; +void headerMergeLegacySigs(Header h, const Header sigh) + /*@modifies h, sigh @*/; /** \ingroup header * Regenerate signature header. @@ -853,10 +853,11 @@ int headerVerifyInfo(int il, int dl, const void * pev, void * iv, int negate) * @param ts transaction set * @param uh unloaded header blob * @param uc no. of bytes in blob (or 0 to disable) - * @retval *msg verification error message + * @retval *msg verification error message (or NULL) * @return RPMRC_OK on success */ -rpmRC headerCheck(rpmts ts, const void * uh, size_t uc, const char ** msg) +rpmRC headerCheck(rpmts ts, const void * uh, size_t uc, + /*@out@*/ /*@null@*/ const char ** msg) /*@globals rpmGlobalMacroContext, fileSystem, internalState @*/ /*@modifies ts, *msg, rpmGlobalMacroContext, fileSystem, internalState @*/; @@ -866,12 +867,13 @@ rpmRC headerCheck(rpmts ts, const void * uh, size_t uc, const char ** msg) * @param ts transaction set * @param fd file handle * @retval hdrp address of header (or NULL) - * @retval *msg verification error message + * @retval *msg verification error message (or NULL) * @return RPMRC_OK on success */ -rpmRC rpmReadHeader(rpmts ts, FD_t fd, Header *hdrp, const char ** msg) +rpmRC rpmReadHeader(rpmts ts, FD_t fd, /*@out@*/ Header *hdrp, + /*@out@*/ /*@null@*/ const char ** msg) /*@globals rpmGlobalMacroContext, fileSystem, internalState @*/ - /*@modifies ts, *msg, rpmGlobalMacroContext, + /*@modifies ts, *hdrp, *msg, rpmGlobalMacroContext, fileSystem, internalState @*/; /** diff --git a/lib/signature.c b/lib/signature.c index 93221da84..f18f27298 100644 --- a/lib/signature.c +++ b/lib/signature.c @@ -19,6 +19,8 @@ #include "debug.h" /*@access Header@*/ /* XXX compared with NULL */ +/*@access entryInfo @*/ /* XXX rpmReadSignature */ +/*@access indexEntry @*/ /* XXX rpmReadSignature */ /*@access FD_t@*/ /* XXX compared with NULL */ /*@access DIGEST_CTX@*/ /* XXX compared with NULL */ /*@access pgpDig@*/ @@ -163,45 +165,56 @@ rpmRC rpmReadSignature(FD_t fd, Header * sighp, sigType sig_type, int xx; int i; +/*@-boundswrite@*/ if (sighp) *sighp = NULL; buf[0] = '\0'; +/*@=boundswrite@*/ if (sig_type != RPMSIGTYPE_HEADERSIG) goto exit; + memset(block, 0, sizeof(block)); if ((xx = timedRead(fd, (char *)block, sizeof(block))) != sizeof(block)) { - snprintf(buf, sizeof(buf), + (void) snprintf(buf, sizeof(buf), _("sigh size(%d): BAD, read returned %d\n"), sizeof(block), xx); goto exit; } if (memcmp(block, header_magic, sizeof(header_magic))) { - snprintf(buf, sizeof(buf), + (void) snprintf(buf, sizeof(buf), _("sigh magic: BAD\n")); goto exit; } +/*@-boundsread@*/ il = ntohl(block[2]); +/*@=boundsread@*/ if (il < 0 || il > 32) { - snprintf(buf, sizeof(buf), + (void) snprintf(buf, sizeof(buf), _("sigh tags: BAD, no. of tags(%d) out of range\n"), il); goto exit; } +/*@-boundsread@*/ dl = ntohl(block[3]); +/*@=boundsread@*/ if (dl < 0 || dl > 8192) { - snprintf(buf, sizeof(buf), + (void) snprintf(buf, sizeof(buf), _("sigh data: BAD, no. of bytes(%d) out of range\n"), dl); goto exit; } +/*@-sizeoftype@*/ nb = (il * sizeof(struct entryInfo_s)) + dl; +/*@=sizeoftype@*/ ei = xmalloc(sizeof(il) + sizeof(dl) + nb); +/*@-bounds@*/ ei[0] = block[2]; ei[1] = block[3]; pe = (entryInfo) &ei[2]; +/*@=bounds@*/ dataStart = (unsigned char *) (pe + il); if ((xx = timedRead(fd, (char *)pe, nb)) != nb) { - snprintf(buf, sizeof(buf), + (void) snprintf(buf, sizeof(buf), _("sigh blob(%d): BAD, read returned %d\n"), nb, xx); goto exit; } @@ -209,7 +222,7 @@ rpmRC rpmReadSignature(FD_t fd, Header * sighp, sigType sig_type, /* Check (and convert) the 1st tag element. */ xx = headerVerifyInfo(1, dl, pe, &entry->info, 0); if (xx != -1) { - snprintf(buf, sizeof(buf), + (void) snprintf(buf, sizeof(buf), _("tag[%d]: BAD, tag %d type %d offset %d count %d\n"), 0, entry->info.tag, entry->info.type, entry->info.offset, entry->info.count); @@ -225,7 +238,7 @@ rpmRC rpmReadSignature(FD_t fd, Header * sighp, sigType sig_type, /*@=sizeoftype@*/ if (entry->info.offset >= dl) { - snprintf(buf, sizeof(buf), + (void) snprintf(buf, sizeof(buf), _("region offset: BAD, tag %d type %d offset %d count %d\n"), entry->info.tag, entry->info.type, entry->info.offset, entry->info.count); @@ -234,19 +247,19 @@ rpmRC rpmReadSignature(FD_t fd, Header * sighp, sigType sig_type, /* Is there an immutable header region tag trailer? */ dataEnd = dataStart + entry->info.offset; +/*@-sizeoftype@*/ /*@-bounds@*/ (void) memcpy(info, dataEnd, REGION_TAG_COUNT); /*@=bounds@*/ dataEnd += REGION_TAG_COUNT; -/*@-sizeoftype@*/ xx = headerVerifyInfo(1, dl, info, &entry->info, 1); if (xx != -1 || !(entry->info.tag == RPMTAG_HEADERSIGNATURES && entry->info.type == RPM_BIN_TYPE && entry->info.count == REGION_TAG_COUNT)) { - snprintf(buf, sizeof(buf), + (void) snprintf(buf, sizeof(buf), _("region trailer: BAD, tag %d type %d offset %d count %d\n"), entry->info.tag, entry->info.type, entry->info.offset, entry->info.count); @@ -260,18 +273,20 @@ rpmRC rpmReadSignature(FD_t fd, Header * sighp, sigType sig_type, /* Is the no. of tags in the region less than the total no. of tags? */ ril = entry->info.offset/sizeof(*pe); if ((entry->info.offset % sizeof(*pe)) || ril > il) { - snprintf(buf, sizeof(buf), + (void) snprintf(buf, sizeof(buf), _("region size: BAD, ril(%d) > il(%d)\n"), ril, il); goto exit; } } /* Sanity check signature tags */ +/*@-boundswrite@*/ memset(info, 0, sizeof(*info)); +/*@=boundswrite@*/ for (i = 1; i < il; i++) { xx = headerVerifyInfo(1, dl, pe+i, &entry->info, 0); if (xx != -1) { - snprintf(buf, sizeof(buf), + (void) snprintf(buf, sizeof(buf), _("sigh tag[%d]: BAD, tag %d type %d offset %d count %d\n"), i, entry->info.tag, entry->info.type, entry->info.offset, entry->info.count); @@ -282,7 +297,7 @@ rpmRC rpmReadSignature(FD_t fd, Header * sighp, sigType sig_type, /* OK, blob looks sane, load the header. */ sigh = headerLoad(ei); if (sigh == NULL) { - snprintf(buf, sizeof(buf), _("sigh load: BAD\n")); + (void) snprintf(buf, sizeof(buf), _("sigh load: BAD\n")); goto exit; } sigh->flags |= HEADERFLAG_ALLOCATED; @@ -293,7 +308,7 @@ rpmRC rpmReadSignature(FD_t fd, Header * sighp, sigType sig_type, /* Position at beginning of header. */ if (pad && (xx = timedRead(fd, (char *)block, pad)) != pad) { - snprintf(buf, sizeof(buf), + (void) snprintf(buf, sizeof(buf), _("sigh pad(%d): BAD, read %d bytes\n"), pad, xx); goto exit; } @@ -304,11 +319,11 @@ rpmRC rpmReadSignature(FD_t fd, Header * sighp, sigType sig_type, } exit: - if (rc == RPMRC_OK && sighp && sigh) +/*@-boundswrite@*/ + if (sighp && sigh && rc == RPMRC_OK) *sighp = headerLink(sigh); sigh = headerFree(sigh); -/*@-boundswrite@*/ if (msg != NULL) { buf[sizeof(buf)-1] = '\0'; *msg = xstrdup(buf); diff --git a/lib/signature.h b/lib/signature.h index 69f8d2a88..9c4ca2067 100644 --- a/lib/signature.h +++ b/lib/signature.h @@ -47,9 +47,9 @@ Header rpmNewSignature(void) * @return rpmRC return code */ rpmRC rpmReadSignature(FD_t fd, /*@null@*/ /*@out@*/ Header *sighp, - sigType sig_type, const char ** msg) + sigType sig_type, /*@null@*/ /*@out@*/ const char ** msg) /*@globals fileSystem @*/ - /*@modifies fd, *sighp, fileSystem @*/; + /*@modifies fd, *sighp, *msg, fileSystem @*/; /** \ingroup signature * Write signature header. diff --git a/rpmdb/fprint.h b/rpmdb/fprint.h index 2b6bb9fef..0012d4b5e 100644 --- a/rpmdb/fprint.h +++ b/rpmdb/fprint.h @@ -75,8 +75,9 @@ extern "C" { */ int rpmdbFindFpList(/*@null@*/ rpmdb db, fingerPrint * fpList, /*@out@*/ dbiIndexSet * matchList, int numItems) - /*@globals rpmGlobalMacroContext, fileSystem @*/ - /*@modifies db, *matchList, rpmGlobalMacroContext, fileSystem @*/; + /*@globals rpmGlobalMacroContext, fileSystem, internalState @*/ + /*@modifies db, *matchList, rpmGlobalMacroContext, + fileSystem, internalState @*/; /* Be carefull with the memory... assert(*fullName == '/' || !scareMemory) */ diff --git a/rpmdb/header.c b/rpmdb/header.c index d8c79c564..69017a5ec 100644 --- a/rpmdb/header.c +++ b/rpmdb/header.c @@ -397,11 +397,13 @@ static int dataLength(int_32 type, hPTR_t p, int_32 count, int onDisk, case RPM_STRING_TYPE: if (count != 1) return -1; +/*@-boundsread@*/ while (*s++) { if (se && s > se) return -1; length++; } +/*@=boundsread@*/ length++; /* count nul terminator too. */ break; @@ -413,11 +415,13 @@ static int dataLength(int_32 type, hPTR_t p, int_32 count, int onDisk, if (onDisk) { while (count--) { length++; /* count nul terminator too */ +/*@-boundsread@*/ while (*s++) { if (se && s > se) return -1; length++; } +/*@=boundsread@*/ } } else { const char ** av = (const char **)p; @@ -500,8 +504,10 @@ static int regionSwab(/*@null@*/ indexEntry entry, int il, int dl, return -1; if (hdrchkData(ie.info.offset)) return -1; +/*@-boundsread@*/ if (hdrchkAlign(ie.info.type, ie.info.offset)) return -1; +/*@=boundsread@*/ ie.data = t = dataStart + ie.info.offset; if (dataEnd && t >= dataEnd) @@ -1078,7 +1084,9 @@ Header headerLoad(/*@kept@*/ void * uh) if (hdrchkData(off)) goto errxit; if (off) { +/*@-sizeoftype@*/ size_t nb = REGION_TAG_COUNT; +/*@=sizeoftype@*/ int_32 * stei = memcpy(alloca(nb), dataStart + off, nb); rdl = -ntohl(stei[2]); /* negative offset */ ril = rdl/sizeof(*pe); @@ -1834,10 +1842,12 @@ grabData(int_32 type, hPTR_t p, int_32 c, /*@out@*/ int * lengthPtr) int length; length = dataLength(type, p, c, 0, NULL); +/*@-branchstate@*/ if (length > 0) { data = xmalloc(length); copyData(type, data, p, c, length); } +/*@=branchstate@*/ if (lengthPtr) *lengthPtr = length; diff --git a/rpmdb/legacy.c b/rpmdb/legacy.c index b88cfbbc7..1aafd4454 100644 --- a/rpmdb/legacy.c +++ b/rpmdb/legacy.c @@ -37,8 +37,9 @@ * @return -1 on error, otherwise, an open file descriptor */ static int open_dso(const char * path, /*@null@*/ pid_t * pidp, /*@null@*/ size_t *fsizep) - /*@globals rpmGlobalMacroContext, internalState @*/ - /*@modifies *pidp, *fsizep, rpmGlobalMacroContext, internalState @*/ + /*@globals rpmGlobalMacroContext, fileSystem, internalState @*/ + /*@modifies *pidp, *fsizep, rpmGlobalMacroContext, + fileSystem, internalState @*/ { /*@only@*/ static const char * cmd = NULL; diff --git a/rpmdb/rpmdb.c b/rpmdb/rpmdb.c index 6ccc290ed..1081100e3 100644 --- a/rpmdb/rpmdb.c +++ b/rpmdb/rpmdb.c @@ -769,8 +769,8 @@ static int blockSignals(/*@unused@*/ rpmdb db, /*@out@*/ sigset_t * oldMask) */ /*@mayexit@*/ static int unblockSignals(/*@unused@*/ rpmdb db, sigset_t * oldMask) - /*@globals rpmdbRock, fileSystem @*/ - /*@modifies rpmdbRock, fileSystem @*/ + /*@globals rpmdbRock, fileSystem, internalState @*/ + /*@modifies rpmdbRock, fileSystem, internalState @*/ { (void) rpmdbCheckSignals(); return sigprocmask(SIG_SETMASK, oldMask, NULL); @@ -1155,9 +1155,9 @@ int rpmdbVerify(const char * prefix) */ static int rpmdbFindByFile(rpmdb db, /*@null@*/ const char * filespec, DBT * key, DBT * data, /*@out@*/ dbiIndexSet * matches) - /*@globals rpmGlobalMacroContext, fileSystem @*/ + /*@globals rpmGlobalMacroContext, fileSystem, internalState @*/ /*@modifies db, *key, *data, *matches, rpmGlobalMacroContext, - fileSystem @*/ + fileSystem, internalState @*/ /*@requires maxSet(matches) >= 0 @*/ { HGE_t hge = (HGE_t)headerGetEntryMinMemory; @@ -1371,9 +1371,9 @@ static rpmRC dbiFindMatches(dbiIndex dbi, DBC * dbcursor, /*@null@*/ const char * version, /*@null@*/ const char * release, /*@out@*/ dbiIndexSet * matches) - /*@globals rpmGlobalMacroContext, fileSystem @*/ + /*@globals rpmGlobalMacroContext, fileSystem, internalState @*/ /*@modifies dbi, *dbcursor, *key, *data, *matches, - rpmGlobalMacroContext, fileSystem @*/ + rpmGlobalMacroContext, fileSystem, internalState @*/ /*@requires maxSet(matches) >= 0 @*/ { int gotMatches = 0; @@ -1467,9 +1467,9 @@ exit: */ static rpmRC dbiFindByLabel(dbiIndex dbi, DBC * dbcursor, DBT * key, DBT * data, /*@null@*/ const char * arg, /*@out@*/ dbiIndexSet * matches) - /*@globals rpmGlobalMacroContext, fileSystem @*/ + /*@globals rpmGlobalMacroContext, fileSystem, internalState @*/ /*@modifies dbi, *dbcursor, *key, *data, *matches, - rpmGlobalMacroContext, fileSystem @*/ + rpmGlobalMacroContext, fileSystem, internalState @*/ /*@requires maxSet(matches) >= 0 @*/ { const char * release; @@ -1604,8 +1604,8 @@ struct _rpmdbMatchIterator { * @return 0 on success */ static int miFreeHeader(rpmdbMatchIterator mi, dbiIndex dbi) - /*@globals fileSystem @*/ - /*@modifies mi, fileSystem @*/ + /*@globals fileSystem, internalState @*/ + /*@modifies mi, fileSystem, internalState @*/ { int rc = 0; diff --git a/rpmdb/rpmdb.h b/rpmdb/rpmdb.h index a9175df9b..197a7b1cf 100644 --- a/rpmdb/rpmdb.h +++ b/rpmdb/rpmdb.h @@ -1004,8 +1004,8 @@ int rpmdbSetHdrChk(/*@null@*/ rpmdbMatchIterator mi, /*@null@*/ rpmts ts, /*@only@*/ /*@null@*/ rpmdbMatchIterator rpmdbInitIterator(/*@null@*/ rpmdb db, rpmTag rpmtag, /*@null@*/ const void * keyp, size_t keylen) - /*@globals rpmGlobalMacroContext, fileSystem @*/ - /*@modifies db, rpmGlobalMacroContext, fileSystem @*/; + /*@globals rpmGlobalMacroContext, fileSystem, internalState @*/ + /*@modifies db, rpmGlobalMacroContext, fileSystem, internalState @*/; /** \ingroup rpmdb * Return next package header from iteration. @@ -1014,16 +1014,16 @@ rpmdbMatchIterator rpmdbInitIterator(/*@null@*/ rpmdb db, rpmTag rpmtag, */ /*@null@*/ Header rpmdbNextIterator(/*@null@*/ rpmdbMatchIterator mi) - /*@globals rpmGlobalMacroContext, fileSystem @*/ - /*@modifies mi, rpmGlobalMacroContext, fileSystem @*/; + /*@globals rpmGlobalMacroContext, fileSystem, internalState @*/ + /*@modifies mi, rpmGlobalMacroContext, fileSystem, internalState @*/; /** \ingroup rpmdb * Check rpmdb signal handler for trapped signal exit. */ /*@mayexit@*/ int rpmdbCheckSignals(void) - /*@globals fileSystem @*/ - /*@modifies fileSystem @*/; + /*@globals fileSystem, internalState @*/ + /*@modifies fileSystem, internalState @*/; /** \ingroup rpmdb * Destroy rpm database iterator. @@ -1032,8 +1032,8 @@ int rpmdbCheckSignals(void) */ /*@null@*/ rpmdbMatchIterator rpmdbFreeIterator(/*@only@*/ /*@null@*/rpmdbMatchIterator mi) - /*@globals rpmGlobalMacroContext, fileSystem @*/ - /*@modifies mi, rpmGlobalMacroContext, fileSystem @*/; + /*@globals rpmGlobalMacroContext, fileSystem, internalState @*/ + /*@modifies mi, rpmGlobalMacroContext, fileSystem, internalState @*/; /** \ingroup rpmdb * Add package header to rpm database and indices. @@ -1046,8 +1046,8 @@ rpmdbMatchIterator rpmdbFreeIterator(/*@only@*/ /*@null@*/rpmdbMatchIterator mi) */ int rpmdbAdd(/*@null@*/ rpmdb db, int iid, Header h, /*@null@*/ rpmts ts, /*@null@*/ rpmRC (*hdrchk) (rpmts ts, const void *uh, size_t uc, const char ** msg)) - /*@globals rpmGlobalMacroContext, fileSystem @*/ - /*@modifies db, h, rpmGlobalMacroContext, fileSystem @*/; + /*@globals rpmGlobalMacroContext, fileSystem, internalState @*/ + /*@modifies db, h, rpmGlobalMacroContext, fileSystem, internalState @*/; /** \ingroup rpmdb * Remove package header from rpm database and indices. @@ -1061,8 +1061,8 @@ int rpmdbAdd(/*@null@*/ rpmdb db, int iid, Header h, /*@null@*/ rpmts ts, int rpmdbRemove(/*@null@*/ rpmdb db, /*@unused@*/ int rid, unsigned int hdrNum, /*@null@*/ rpmts ts, /*@null@*/ rpmRC (*hdrchk) (rpmts ts, const void *uh, size_t uc, const char ** msg)) - /*@globals rpmGlobalMacroContext, fileSystem @*/ - /*@modifies db, rpmGlobalMacroContext, fileSystem @*/; + /*@globals rpmGlobalMacroContext, fileSystem, internalState @*/ + /*@modifies db, rpmGlobalMacroContext, fileSystem, internalState @*/; /** \ingroup rpmdb * Rebuild database indices from package headers. diff --git a/rpmio/macro.c b/rpmio/macro.c index 1498f689b..e155ef3c2 100644 --- a/rpmio/macro.c +++ b/rpmio/macro.c @@ -50,6 +50,12 @@ typedef FILE * FD_t; #include "debug.h" +#if defined(__LCLINT__) +/*@-exportheader@*/ +extern const unsigned short int **__ctype_b_loc (void) /*@*/; +/*@=exportheader@*/ +#endif + /*@access FD_t@*/ /* XXX compared with NULL */ /*@access MacroContext@*/ /*@access MacroEntry@*/ diff --git a/rpmio/rpmrpc.c b/rpmio/rpmrpc.c index 80c10f987..2edaa013d 100644 --- a/rpmio/rpmrpc.c +++ b/rpmio/rpmrpc.c @@ -13,6 +13,7 @@ #include "ugid.h" #include "debug.h" +/*@access DIR@*/ /*@access FD_t@*/ /*@access urlinfo@*/ @@ -1174,7 +1175,9 @@ fprintf(stderr, "*** ftpOpendir(%s)\n", path); /*@=abstract@*/ mydir->fd = ftpmagicdir; +/*@-usereleased@*/ mydir->data = (char *) dp; +/*@=usereleased@*/ mydir->allocation = nb; mydir->size = ac; mydir->offset = -1; @@ -1242,7 +1245,9 @@ fprintf(stderr, "*** ftpOpendir(%s)\n", path); } av[ac] = NULL; +/*@-kepttrans@*/ return (DIR *) mydir; +/*@=kepttrans@*/ } /*@=boundswrite@*/ |