BSD4.3 ls: sign extension bug

Reg Quinton reggers at ria.ccs.uwo.ca
Thu Jul 26 00:40:02 AEST 1990


Christ! the things you discover when the accounting office gets involved.
Our accounting office wanted to use all available gid/uid numbers. We're
running into some problems with those over 2^15 but less than 2^16 on
*some* systems.

We've discovered that a number of systems have problems with sign
extension of the gid/uid pairs stored in the fstat structures (ie. file
information). These numbers are _supposed_ to be "ushort" but often lazy
programmers represent them as "short" -- and the problem starts.

We've seen this problem on Mips (not /bin/ls but /usr/bsd43/bin/ls), and
Sun. No doubt it exists on others as well who are using BSD sources.

Oh well, BSD 4.3 ls is easily fixed, context diff follows:

*** ls.c.orig	Wed Jul 25 09:36:30 1990
--- ls.c	Wed Jul 25 09:37:30 1990
***************
*** 12,17 ****
--- 12,18 ----

  #ifndef lint
  static char sccsid[] = "@(#)ls.c	5.6 (Berkeley) 5/12/86";
+ static char uwoid[] = "Wed Jul 25 09:37:20 EDT 1990; Reg Quinton";
  #endif not lint

  /*
***************
*** 33,40 ****
  	ino_t	fnum;		/* inode number of file */
  	short	fflags;		/* mode&~S_IFMT, perhaps ISARG */
  	short	fnl;		/* number of links */
! 	short	fuid;		/* owner id */
! 	short	fgid;		/* group id */
  	long	fsize;		/* file size */
  	long	fblks;		/* number of blocks used */
  	time_t	fmtime;		/* time (modify or access or create) */
--- 34,41 ----
  	ino_t	fnum;		/* inode number of file */
  	short	fflags;		/* mode&~S_IFMT, perhaps ISARG */
  	short	fnl;		/* number of links */
! 	ushort	fuid;		/* owner id */
! 	ushort	fgid;		/* group id */
  	long	fsize;		/* file size */
  	long	fblks;		/* number of blocks used */
  	time_t	fmtime;		/* time (modify or access or create) */



More information about the Comp.sys.sun mailing list