diff options
author | delphij <delphij@FreeBSD.org> | 2011-09-02 17:05:34 +0000 |
---|---|---|
committer | delphij <delphij@FreeBSD.org> | 2011-09-02 17:05:34 +0000 |
commit | 0e6cabaab185606f0cd69428aa2a8084349da3a9 (patch) | |
tree | 41ce238750e2d318d4e2f9be352892921bfa9b88 | |
parent | 3cf33970bf0ab33ba3a8f7a526e67ccc47e341e6 (diff) | |
download | FreeBSD-src-0e6cabaab185606f0cd69428aa2a8084349da3a9.zip FreeBSD-src-0e6cabaab185606f0cd69428aa2a8084349da3a9.tar.gz |
Fix the check in dircheck() on namlen.
The value of namlen is copied from on-disk d_namlen, which is a 8-bit
unsigned integer which can never exceed MAXNAMLEN (255) so the test is
always true. Moreover, UFS does not allow d_namelen being zero.
Change namlen from u_int to u_int8_t, and replace the unneeded test
with a useful test.
PR: bin/160339
Submitted by: Eugene Grosbein <eugen grosbein.pp.ru>
MFC after: 2 weeks
Approved by: re (kib)
-rw-r--r-- | sbin/fsck_ffs/dir.c | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/sbin/fsck_ffs/dir.c b/sbin/fsck_ffs/dir.c index da838b0..7815fe6 100644 --- a/sbin/fsck_ffs/dir.c +++ b/sbin/fsck_ffs/dir.c @@ -210,7 +210,7 @@ dircheck(struct inodesc *idesc, struct direct *dp) size_t size; char *cp; u_char type; - u_int namlen; + u_int8_t namlen; int spaceleft; spaceleft = DIRBLKSIZ - (idesc->id_loc % DIRBLKSIZ); @@ -225,7 +225,7 @@ dircheck(struct inodesc *idesc, struct direct *dp) type = dp->d_type; if (dp->d_reclen < size || idesc->id_filesize < size || - namlen > MAXNAMLEN || + namlen == 0 || type > 15) goto bad; for (cp = dp->d_name, size = 0; size < namlen; size++) |