Subject: kern/534: Bug in MSDOSFS
To: None <gnats-admin@sun-lamp.cs.berkeley.edu>
From: None <mikeh@hds.com>
List: netbsd-bugs
Date: 10/26/1994 12:20:04
>Number:         534
>Category:       kern
>Synopsis:       MSDOSFS: EOF flag not properly set in msdosfs_readdir().
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    gnats-admin (Kernel Bug People)
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Wed Oct 26 12:20:03 1994
>Originator:     Mike Hartman
>Organization:
Human Designed Systems, Inc.
>Release:        current
>Environment:
	
System: SunOS hdssun1 4.1.3 1 sun4m
Architecture: sun4

>Description:
There are two instances where the EOF flag is not properly set.  In the first
instance, the uio offset is at or past the EOF, but the EOF flag is not set.
In the second instance, the math to determine EOF is missing parenthesis to
properly order the expression evaluation.

>How-To-Repeat:

>Fix:
*** src/src/sys/msdosfs/msdosfs_vnops.c	Wed Oct 26 12:44:37 1994
--- src/src/sys/msdosfs/msdosfs_vnops.c	Wed Oct 26 14:19:45 1994
***************
*** 1499,1506 ****
  		on = (uio->uio_offset - bias) & pmp->pm_crbomask;
  		n = min((u_long) (pmp->pm_bpcluster - on), uio->uio_resid);
  		diff = dep->de_FileSize - (uio->uio_offset - bias);
! 		if (diff <= 0)
  			return 0;
  		if (diff < n)
  			n = diff;
  		error = pcbmap(dep, lbn, &bn, &cn);
--- 1499,1508 ----
  		on = (uio->uio_offset - bias) & pmp->pm_crbomask;
  		n = min((u_long) (pmp->pm_bpcluster - on), uio->uio_resid);
  		diff = dep->de_FileSize - (uio->uio_offset - bias);
! 		if (diff <= 0) {
! 			*ap->a_eofflag = 1;
  			return 0;
+ 		}
  		if (diff < n)
  			n = diff;
  		error = pcbmap(dep, lbn, &bn, &cn);
***************
*** 1638,1648 ****
  	uio->uio_resid += lost;
  
  	/*
! 	 * I don't know why we bother setting this eofflag, getdirentries()
! 	 * in vfs_syscalls.c doesn't bother to look at it when we return.
! 	 * (because NFS uses it in nfs_serv.c -- JMP)
  	 */
! 	if (dep->de_FileSize - uio->uio_offset - bias <= 0)
  		*ap->a_eofflag = 1;
  	else
  		*ap->a_eofflag = 0;
--- 1640,1648 ----
  	uio->uio_resid += lost;
  
  	/*
! 	 * Set the eofflag.
  	 */
! 	if (dep->de_FileSize - (uio->uio_offset - bias) <= 0)
  		*ap->a_eofflag = 1;
  	else
  		*ap->a_eofflag = 0;
>Audit-Trail:
>Unformatted: