diff options
Diffstat (limited to 'bsdfsck/dir.c')
-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) |