Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 2 Sep 2011 17:05:34 +0000 (UTC)
From:      Xin LI <delphij@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r225338 - head/sbin/fsck_ffs
Message-ID:  <201109021705.p82H5YlB008183@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: delphij
Date: Fri Sep  2 17:05:34 2011
New Revision: 225338
URL: http://svn.freebsd.org/changeset/base/225338

Log:
  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)

Modified:
  head/sbin/fsck_ffs/dir.c

Modified: head/sbin/fsck_ffs/dir.c
==============================================================================
--- head/sbin/fsck_ffs/dir.c	Fri Sep  2 17:05:11 2011	(r225337)
+++ head/sbin/fsck_ffs/dir.c	Fri Sep  2 17:05:34 2011	(r225338)
@@ -210,7 +210,7 @@ dircheck(struct inodesc *idesc, struct d
 	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 d
 	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++)



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201109021705.p82H5YlB008183>