diff options
author | jbj <devnull@localhost> | 2002-07-02 23:54:35 +0000 |
---|---|---|
committer | jbj <devnull@localhost> | 2002-07-02 23:54:35 +0000 |
commit | e5fb770e7d9aac53a513965c0f2bcf360934794b (patch) | |
tree | d8d581ec8f694a4811172b401e4dcda68898954a /rpmio | |
parent | 77076c7c8d83f8b783634c7328b132b938389987 (diff) | |
download | librpm-tizen-e5fb770e7d9aac53a513965c0f2bcf360934794b.tar.gz librpm-tizen-e5fb770e7d9aac53a513965c0f2bcf360934794b.tar.bz2 librpm-tizen-e5fb770e7d9aac53a513965c0f2bcf360934794b.zip |
Add boundsread annotations throughout, enable +bounds checking.
Start narrowing the scope of bounds annotations by adding more annotations.
CVS patchset: 5537
CVS date: 2002/07/02 23:54:35
Diffstat (limited to 'rpmio')
-rw-r--r-- | rpmio/.lclintrc | 3 | ||||
-rw-r--r-- | rpmio/digest.c | 4 | ||||
-rw-r--r-- | rpmio/fts.c | 2 | ||||
-rw-r--r-- | rpmio/macro.c | 2 | ||||
-rw-r--r-- | rpmio/rpmio.c | 21 | ||||
-rw-r--r-- | rpmio/rpmlog.c | 2 | ||||
-rw-r--r-- | rpmio/rpmpgp.c | 2 | ||||
-rw-r--r-- | rpmio/rpmrpc.c | 8 | ||||
-rw-r--r-- | rpmio/rpmurl.h | 3 | ||||
-rw-r--r-- | rpmio/strcasecmp.c | 4 | ||||
-rw-r--r-- | rpmio/url.c | 6 |
11 files changed, 53 insertions, 4 deletions
diff --git a/rpmio/.lclintrc b/rpmio/.lclintrc index 9d47e41a4..47210a3d8 100644 --- a/rpmio/.lclintrc +++ b/rpmio/.lclintrc @@ -13,8 +13,7 @@ +strict # lclint level # --- in progress -#+bounds # 334 -+boundswrite # 152 ++bounds # --- +partial artifacts -declundef diff --git a/rpmio/digest.c b/rpmio/digest.c index 29ec824e8..174672061 100644 --- a/rpmio/digest.c +++ b/rpmio/digest.c @@ -35,6 +35,7 @@ struct DIGEST_CTX_s { /*@modifies param, digest @*/; /*!< Digest finish. */ }; +/*@-boundsread@*/ DIGEST_CTX rpmDigestDup(DIGEST_CTX octx) { @@ -42,6 +43,7 @@ rpmDigestDup(DIGEST_CTX octx) nctx->param = memcpy(xcalloc(1, nctx->paramlen), octx->param, nctx->paramlen); return nctx; } +/*@=boundsread@*/ DIGEST_CTX rpmDigestInit(pgpHashAlgo hashalgo, rpmDigestFlags flags) @@ -88,7 +90,9 @@ rpmDigestInit(pgpHashAlgo hashalgo, rpmDigestFlags flags) /*@notreached@*/ break; } +/*@-boundsread@*/ xx = (*ctx->Reset) (ctx->param); +/*@=boundsread@*/ DPRINTF((stderr, "*** Init(%x) ctx %p param %p\n", flags, ctx, ctx->param)); return ctx; diff --git a/rpmio/fts.c b/rpmio/fts.c index 103921987..8052281d9 100644 --- a/rpmio/fts.c +++ b/rpmio/fts.c @@ -1,3 +1,4 @@ +/*@-boundsread@*/ /*@-sysunrecog -noeffectuncon -nullpass -sizeoftype -unrecog -usereleased @*/ /*@-compdef -compmempass -dependenttrans -retalias @*/ /*- @@ -1186,3 +1187,4 @@ bail: } /*@=compdef =compmempass =dependenttrans =retalias @*/ /*@=sysunrecog =noeffectuncon =nullpass =sizeoftype =unrecog =usereleased @*/ +/*@=boundsread@*/ diff --git a/rpmio/macro.c b/rpmio/macro.c index a5276b669..4610555fb 100644 --- a/rpmio/macro.c +++ b/rpmio/macro.c @@ -1,3 +1,4 @@ +/*@-boundsread@*/ /** \ingroup rpmrc rpmio * \file rpmio/macro.c */ @@ -2043,3 +2044,4 @@ main(int argc, char *argv[]) } #endif /* EVAL_MACROS */ #endif /* DEBUG_MACROS */ +/*@=boundsread@*/ diff --git a/rpmio/rpmio.c b/rpmio/rpmio.c index ff6000405..3ae20a5cd 100644 --- a/rpmio/rpmio.c +++ b/rpmio/rpmio.c @@ -743,6 +743,7 @@ static int mygethostbyname(const char * host, } #endif +/*@-boundsread@*/ /*@-compdef@*/ /* FIX: address->s_addr undefined. */ static int getHostAddress(const char * host, /*@out@*/ struct in_addr * address) /*@globals errno @*/ @@ -765,6 +766,7 @@ static int getHostAddress(const char * host, /*@out@*/ struct in_addr * address) return 0; } /*@=compdef@*/ +/*@=boundsread@*/ static int tcpConnect(FD_t ctrl, const char * host, int port) /*@globals fileSystem @*/ @@ -1302,10 +1304,12 @@ int ufdCopy(FD_t sfd, FD_t tfd) int notifier = -1; if (urlNotify) { +/*@-boundsread@*/ /*@-noeffectuncon @*/ /* FIX: check rc */ (void)(*urlNotify) (NULL, RPMCALLBACK_INST_OPEN_FILE, 0, 0, NULL, urlNotifyData); /*@=noeffectuncon @*/ +/*@=boundsread@*/ } while (1) { @@ -1329,10 +1333,12 @@ int ufdCopy(FD_t sfd, FD_t tfd) if (urlNotify && urlNotifyCount > 0) { int n = itemsCopied/urlNotifyCount; if (n != notifier) { +/*@-boundsread@*/ /*@-noeffectuncon @*/ /* FIX: check rc */ (void)(*urlNotify) (NULL, RPMCALLBACK_INST_PROGRESS, itemsCopied, 0, NULL, urlNotifyData); /*@=noeffectuncon @*/ +/*@=boundsread@*/ notifier = n; } } @@ -1344,10 +1350,12 @@ int ufdCopy(FD_t sfd, FD_t tfd) /*@=modfilesys@*/ if (urlNotify) { +/*@-boundsread@*/ /*@-noeffectuncon @*/ /* FIX: check rc */ (void)(*urlNotify) (NULL, RPMCALLBACK_INST_OPEN_FILE, itemsCopied, itemsCopied, NULL, urlNotifyData); /*@=noeffectuncon @*/ +/*@=boundsread@*/ } return rc; @@ -2150,7 +2158,9 @@ static inline /*@dependent@*/ /*@null@*/ void * gzdFileno(FD_t fd) FDSANE(fd); for (i = fd->nfps; i >= 0; i--) { +/*@-boundsread@*/ FDSTACK_t * fps = &fd->fps[i]; +/*@=boundsread@*/ if (fps->io != gzdio) continue; rc = fps->fp; @@ -2407,7 +2417,9 @@ static inline /*@dependent@*/ void * bzdFileno(FD_t fd) FDSANE(fd); for (i = fd->nfps; i >= 0; i--) { +/*@-boundsread@*/ FDSTACK_t * fps = &fd->fps[i]; +/*@=boundsread@*/ if (fps->io != bzdio) continue; rc = fps->fp; @@ -2655,9 +2667,11 @@ DBGIO(fd, (stderr, "==> Fwrite(%p,%u,%u,%p) %s\n", buf, (unsigned)size, (unsigne /*@=modfilesys@*/ if (fdGetIo(fd) == fpio) { +/*@-boundsread@*/ /*@+voidabstract -nullpass@*/ rc = fwrite(buf, size, nmemb, fdGetFILE(fd)); /*@=voidabstract =nullpass@*/ +/*@=boundsread@*/ return rc; } @@ -2715,7 +2729,9 @@ DBGIO(fd, (stderr, "==> Fclose(%p) %s\n", (fd ? fd : NULL), fdbg(fd))); fd = fdLink(fd, "Fclose"); /*@-branchstate@*/ while (fd->nfps >= 0) { +/*@-boundsread@*/ FDSTACK_t * fps = &fd->fps[fd->nfps]; +/*@=boundsread@*/ if (fps->io == fpio) { FILE *fp; @@ -2981,6 +2997,7 @@ FD_t Fopen(const char *path, const char *fmode) if (path == NULL || fmode == NULL) return NULL; + stdio[0] = '\0'; cvtfmode(fmode, stdio, sizeof(stdio), other, sizeof(other), &end, &flags); if (stdio[0] == '\0') return NULL; @@ -3073,7 +3090,9 @@ int Ferror(FD_t fd) if (fd == NULL) return -1; for (i = fd->nfps; rc == 0 && i >= 0; i--) { +/*@-boundsread@*/ FDSTACK_t * fps = &fd->fps[i]; +/*@=boundsread@*/ int ec; if (fps->io == fpio) { @@ -3107,7 +3126,9 @@ int Fileno(FD_t fd) int i, rc = -1; for (i = fd->nfps ; rc == -1 && i >= 0; i--) { +/*@-boundsread@*/ rc = fd->fps[i].fdno; +/*@=boundsread@*/ } /*@-modfilesys@*/ DBGIO(fd, (stderr, "==> Fileno(%p) rc %d %s\n", (fd ? fd : NULL), rc, fdbg(fd))); diff --git a/rpmio/rpmlog.c b/rpmio/rpmlog.c index 63b17cb99..61d8af412 100644 --- a/rpmio/rpmlog.c +++ b/rpmio/rpmlog.c @@ -1,3 +1,4 @@ +/*@-boundsread@*/ /** \ingroup rpmio * \file rpmio/rpmlog.c */ @@ -261,3 +262,4 @@ rpmlogCallback rpmErrorSetCallback(rpmlogCallback cb) { return rpmlogSetCallback(cb); } +/*@=boundsread@*/ diff --git a/rpmio/rpmpgp.c b/rpmio/rpmpgp.c index 6d422936b..4a585742f 100644 --- a/rpmio/rpmpgp.c +++ b/rpmio/rpmpgp.c @@ -1,3 +1,4 @@ +/*@-boundsread@*/ /** \ingroup rpmio signature * \file rpmio/rpmpgp.c * Routines to handle RFC-2440 detached signatures. @@ -1241,3 +1242,4 @@ exit: return ec; } /*@=boundswrite@*/ +/*@=boundsread@*/ diff --git a/rpmio/rpmrpc.c b/rpmio/rpmrpc.c index 939d061bd..0eeca5ab8 100644 --- a/rpmio/rpmrpc.c +++ b/rpmio/rpmrpc.c @@ -297,6 +297,7 @@ vfs_split_text (char *p) } /*@=boundswrite@*/ +/*@-boundsread@*/ static int is_num (int idx) /*@*/ @@ -305,7 +306,9 @@ is_num (int idx) return 0; return 1; } +/*@=boundsread@*/ +/*@-boundsread@*/ static int is_dos_date(/*@null@*/ const char *str) /*@*/ @@ -315,6 +318,7 @@ is_dos_date(/*@null@*/ const char *str) return 1; return 0; } +/*@=boundsread@*/ static int is_week (/*@null@*/ const char * str, /*@out@*/ struct tm * tim) @@ -1251,8 +1255,10 @@ static struct dirent * ftpReaddir(DIR * dir) dt = (char *) (av + (ac + 1)); i = dir->offset + 1; +/*@-boundsread@*/ if (i < 0 || i >= ac || av[i] == NULL) return NULL; +/*@=boundsread@*/ dir->offset = i; @@ -1260,7 +1266,9 @@ static struct dirent * ftpReaddir(DIR * dir) dp->d_ino = i + 1; /* W2DO? */ dp->d_off = 0; /* W2DO? */ dp->d_reclen = 0; /* W2DO? */ +/*@-boundsread@*/ dp->d_type = dt[i]; +/*@=boundsread@*/ strncpy(dp->d_name, av[i], sizeof(dp->d_name)); /*@+voidabstract@*/ diff --git a/rpmio/rpmurl.h b/rpmio/rpmurl.h index b555d59f4..0f06eb267 100644 --- a/rpmio/rpmurl.h +++ b/rpmio/rpmurl.h @@ -139,8 +139,11 @@ urltype urlIsURL(const char * url) * @retval pathp pointer to path component of url * @return type of url */ +/*@-incondefs@*/ urltype urlPath(const char * url, /*@out@*/ const char ** pathp) + /*@ensures maxSet(*pathp) == 0 /\ maxRead(*pathp) == 0 @*/ /*@modifies *pathp @*/; +/*@=incondefs@*/ /** * Parse URL string into a control structure. diff --git a/rpmio/strcasecmp.c b/rpmio/strcasecmp.c index 669522b4a..774365058 100644 --- a/rpmio/strcasecmp.c +++ b/rpmio/strcasecmp.c @@ -17,8 +17,10 @@ int xstrcasecmp(const char * s1, const char * s2) do { +/*@-boundsread@*/ c1 = xtolower (*p1++); c2 = xtolower (*p2++); +/*@=boundsread@*/ if (c1 == '\0') break; } @@ -38,8 +40,10 @@ int xstrncasecmp(const char *s1, const char *s2, size_t n) do { +/*@-boundsread@*/ c1 = xtolower (*p1++); c2 = xtolower (*p2++); +/*@=boundsread@*/ if (c1 == '\0' || c1 != c2) break; } while (--n > 0); diff --git a/rpmio/url.c b/rpmio/url.c index 2a39b8665..cbb3ebaf6 100644 --- a/rpmio/url.c +++ b/rpmio/url.c @@ -350,6 +350,7 @@ urltype urlIsURL(const char * url) { struct urlstring *us; +/*@-boundsread@*/ if (url && *url) { for (us = urlstrings; us->leadin != NULL; us++) { if (strncmp(url, us->leadin, strlen(us->leadin))) @@ -357,6 +358,7 @@ urltype urlIsURL(const char * url) return us->ret; } } +/*@=boundsread@*/ return URL_IS_UNKNOWN; } @@ -403,7 +405,7 @@ urltype urlPath(const char * url, const char ** pathp) * Split URL into components. The URL can look like * service://user:password@host:port/path */ -/*@-boundswrite@*/ +/*@-bounds@*/ /*@-modfilesys@*/ int urlSplit(const char * url, urlinfo *uret) { @@ -500,7 +502,7 @@ int urlSplit(const char * url, urlinfo *uret) return 0; } /*@=modfilesys@*/ -/*@=boundswrite@*/ +/*@=bounds@*/ int urlGetFile(const char * url, const char * dest) { |