diff options
author | Michael I. Bushnell <mib@gnu.org> | 1994-10-06 17:18:52 +0000 |
---|---|---|
committer | Michael I. Bushnell <mib@gnu.org> | 1994-10-06 17:18:52 +0000 |
commit | fc146959bf2f4bc512467ccb0edc1e33cf463af7 (patch) | |
tree | f4b0ae158d61d9336897638c3aee3f529e873cc3 | |
parent | 5b306b8c5c71825f2cfa3ab9c7d14fb8319d5daf (diff) |
Formerly dir.c.~3~
-rw-r--r-- | bsdfsck/dir.c | 39 |
1 files changed, 20 insertions, 19 deletions
diff --git a/bsdfsck/dir.c b/bsdfsck/dir.c index a97fd40c..6df56df2 100644 --- a/bsdfsck/dir.c +++ b/bsdfsck/dir.c @@ -33,7 +33,7 @@ #ifndef lint /*static char sccsid[] = "from: @(#)dir.c 8.1 (Berkeley) 6/5/93";*/ -static char *rcsid = "$Id: dir.c,v 1.2 1994/08/23 20:08:37 mib Exp $"; +static char *rcsid = "$Id: dir.c,v 1.3 1994/10/06 17:18:52 mib Exp $"; #endif /* not lint */ #include <sys/param.h> @@ -215,9 +215,16 @@ dircheck(idesc, dp) register char *cp; u_char namlen, type; int spaceleft; + spaceleft = DIRBLKSIZ - (idesc->id_loc % DIRBLKSIZ); + if (dp->d_ino >= maxino || + dp->d_reclen == 0 || + dp->d_reclen > spaceleft || + (dp->d_reclen & 0x3) != 0) + return (0); + if (dp->d_ino == 0) + return (1); size = DIRSIZ(!newinofmt, dp); - spaceleft = DIRBLKSIZ - (idesc->id_loc % DIRBLKSIZ); # if (BYTE_ORDER == LITTLE_ENDIAN) if (!newinofmt) { type = dp->d_namlen; @@ -230,23 +237,17 @@ dircheck(idesc, dp) namlen = dp->d_namlen; type = dp->d_type; # endif - if (dp->d_ino < maxino && - dp->d_reclen != 0 && - dp->d_reclen <= spaceleft && - (dp->d_reclen & 0x3) == 0 && - dp->d_reclen >= size && - idesc->id_filesize >= size && - namlen <= MAXNAMLEN && - type <= 15) { - if (dp->d_ino == 0) - return (1); - for (cp = dp->d_name, size = 0; size < namlen; size++) - if (*cp == 0 || (*cp++ == '/')) - return (0); - if (*cp == 0) - return (1); - } - return (0); + if (dp->d_reclen < size || + idesc->id_filesize < size || + namlen > MAXNAMLEN || + type > 15) + return (0); + for (cp = dp->d_name, size = 0; size < namlen; size++) + if (*cp == '\0' || (*cp++ == '/')) + return (0); + if (*cp != '\0') + return (0); + return (1); } direrror(ino, errmesg) |