summaryrefslogtreecommitdiff
path: root/rpmio/fts.c
diff options
context:
space:
mode:
authorjbj <devnull@localhost>2002-06-23 19:47:08 +0000
committerjbj <devnull@localhost>2002-06-23 19:47:08 +0000
commit13d177beb233e111b3ede3edc1340747433a7556 (patch)
treebbc977014bf90f658b0181792ea42aad52b449d6 /rpmio/fts.c
parent05cb73a7ee762065339393057d421613866e0418 (diff)
downloadrpm-13d177beb233e111b3ede3edc1340747433a7556.tar.gz
rpm-13d177beb233e111b3ede3edc1340747433a7556.tar.bz2
rpm-13d177beb233e111b3ede3edc1340747433a7556.zip
Add boundswrite annotations everywhere.
CVS patchset: 5522 CVS date: 2002/06/23 19:47:08
Diffstat (limited to 'rpmio/fts.c')
-rw-r--r--rpmio/fts.c38
1 files changed, 38 insertions, 0 deletions
diff --git a/rpmio/fts.c b/rpmio/fts.c
index 8387e8120..103921987 100644
--- a/rpmio/fts.c
+++ b/rpmio/fts.c
@@ -122,7 +122,9 @@ Fts_open(char * const * argv, int options,
/* Options check. */
if (options & ~FTS_OPTIONMASK) {
+/*@-boundswrite@*/
__set_errno (EINVAL);
+/*@=boundswrite@*/
return (NULL);
}
@@ -161,14 +163,18 @@ Fts_open(char * const * argv, int options,
for (root = NULL, nitems = 0; *argv != NULL; ++argv, ++nitems) {
/* Don't allow zero-length paths. */
if ((len = strlen(*argv)) == 0) {
+/*@-boundswrite@*/
__set_errno (ENOENT);
+/*@=boundswrite@*/
goto mem3;
}
/* Use fchdir(2) speedup only if local DASDI. */
switch (urlIsURL(*argv)) {
case URL_IS_DASH:
+/*@-boundswrite@*/
__set_errno (ENOENT);
+/*@=boundswrite@*/
goto mem3;
/*@notreached@*/ /*@switchbreak@*/ break;
case URL_IS_HTTP:
@@ -256,6 +262,7 @@ fts_load(FTS * sp, FTSENT * p)
* known that the path will fit.
*/
len = p->fts_pathlen = p->fts_namelen;
+/*@-boundswrite@*/
memmove(sp->fts_path, p->fts_name, len + 1);
if ((cp = strrchr(p->fts_name, '/')) && (cp != p->fts_name || cp[1])) {
len = strlen(++cp);
@@ -264,6 +271,7 @@ fts_load(FTS * sp, FTSENT * p)
}
p->fts_accpath = p->fts_path = sp->fts_path;
sp->fts_dev = p->fts_dev;
+/*@=boundswrite@*/
}
int
@@ -304,7 +312,9 @@ Fts_close(FTS * sp)
if (saved_errno != 0) {
/* Free up the stream pointer. */
free(sp);
+/*@-boundswrite@*/
__set_errno (saved_errno);
+/*@=boundswrite@*/
return (-1);
}
}
@@ -421,6 +431,7 @@ Fts_read(FTS * sp)
}
/* Move to the next node on this level. */
+/*@-boundswrite@*/
next: tmp = p;
if ((p = p->fts_link) != NULL) {
free(tmp);
@@ -482,6 +493,7 @@ name: t = sp->fts_path + NAPPEND(p->fts_parent);
/* NUL terminate the pathname. */
sp->fts_path[p->fts_pathlen] = '\0';
+/*@=boundswrite@*/
/*
* Return to the parent directory. If at a root node or came through
@@ -497,7 +509,9 @@ name: t = sp->fts_path + NAPPEND(p->fts_parent);
if (FCHDIR(sp, p->fts_symfd)) {
saved_errno = errno;
(void)__close(p->fts_symfd);
+/*@-boundswrite@*/
__set_errno (saved_errno);
+/*@=boundswrite@*/
SET(FTS_STOP);
return (NULL);
}
@@ -522,7 +536,9 @@ Fts_set(/*@unused@*/ FTS * sp, FTSENT * p, int instr)
{
if (instr != 0 && instr != FTS_AGAIN && instr != FTS_FOLLOW &&
instr != FTS_NOINSTR && instr != FTS_SKIP) {
+/*@-boundswrite@*/
__set_errno (EINVAL);
+/*@=boundswrite@*/
return (1);
}
p->fts_instr = instr;
@@ -536,7 +552,9 @@ Fts_children(FTS * sp, int instr)
int fd;
if (instr != 0 && instr != FTS_NAMEONLY) {
+/*@-boundswrite@*/
__set_errno (EINVAL);
+/*@=boundswrite@*/
return (NULL);
}
@@ -547,7 +565,9 @@ Fts_children(FTS * sp, int instr)
* Errno set to 0 so user can distinguish empty directory from
* an error.
*/
+/*@-boundswrite@*/
__set_errno (0);
+/*@=boundswrite@*/
/* Fatal errors stop here. */
if (ISSET(FTS_STOP))
@@ -710,7 +730,9 @@ fts_build(FTS * sp, int type)
len = NAPPEND(cur);
if (ISSET(FTS_NOCHDIR)) {
cp = sp->fts_path + len;
+/*@-boundswrite@*/
*cp++ = '/';
+/*@=boundswrite@*/
} else {
/* GCC, you're too verbose. */
cp = NULL;
@@ -840,7 +862,9 @@ mem1: saved_errno = errno;
if (ISSET(FTS_NOCHDIR)) {
if (len == sp->fts_pathlen || nitems == 0)
--cp;
+/*@-boundswrite@*/
*cp = '\0';
+/*@=boundswrite@*/
}
/*
@@ -904,7 +928,9 @@ fts_stat(FTS * sp, FTSENT * p, int follow)
if ((*sp->fts_stat) (p->fts_accpath, sbp)) {
saved_errno = errno;
if (!(*sp->fts_lstat) (p->fts_accpath, sbp)) {
+/*@-boundswrite@*/
__set_errno (0);
+/*@=boundswrite@*/
return (FTS_SLNONE);
}
p->fts_errno = saved_errno;
@@ -912,7 +938,9 @@ fts_stat(FTS * sp, FTSENT * p, int follow)
}
} else if ((*sp->fts_lstat) (p->fts_accpath, sbp)) {
p->fts_errno = errno;
+/*@-boundswrite@*/
err: memset(sbp, 0, sizeof(*sbp));
+/*@=boundswrite@*/
return (FTS_NS);
}
@@ -978,6 +1006,7 @@ fts_sort(FTS * sp, FTSENT * head, int nitems)
}
sp->fts_array = a;
}
+/*@-boundswrite@*/
for (ap = sp->fts_array, p = head; p; p = p->fts_link)
*ap++ = p;
qsort((void *)sp->fts_array, nitems, sizeof(*sp->fts_array),
@@ -985,6 +1014,7 @@ fts_sort(FTS * sp, FTSENT * head, int nitems)
for (head = *(ap = sp->fts_array); --nitems; ++ap)
ap[0]->fts_link = ap[1];
ap[0]->fts_link = NULL;
+/*@=boundswrite@*/
return (head);
}
@@ -1009,8 +1039,10 @@ fts_alloc(FTS * sp, const char * name, int namelen)
return (NULL);
/* Copy the name and guarantee NUL termination. */
+/*@-boundswrite@*/
memmove(p->fts_name, name, namelen);
p->fts_name[namelen] = '\0';
+/*@=boundswrite@*/
if (!ISSET(FTS_NOSTAT))
p->fts_statp = (struct stat *)ALIGN(p->fts_name + namelen + 2);
@@ -1061,7 +1093,9 @@ fts_palloc(FTS * sp, size_t more)
sp->fts_path = NULL;
}
sp->fts_path = NULL;
+/*@-boundswrite@*/
__set_errno (ENAMETOOLONG);
+/*@=boundswrite@*/
return (1);
}
p = realloc(sp->fts_path, sp->fts_pathlen);
@@ -1134,7 +1168,9 @@ fts_safe_changedir(FTS * sp, FTSENT * p, int fd, const char * path)
goto bail;
}
if (p->fts_dev != sb.st_dev || p->fts_ino != sb.st_ino) {
+/*@-boundswrite@*/
__set_errno (ENOENT); /* disinformation */
+/*@=boundswrite@*/
ret = -1;
goto bail;
}
@@ -1143,7 +1179,9 @@ bail:
oerrno = errno;
if (fd < 0)
(void)__close(newfd);
+/*@-boundswrite@*/
__set_errno (oerrno);
+/*@=boundswrite@*/
return (ret);
}
/*@=compdef =compmempass =dependenttrans =retalias @*/