🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.bugs.4bsd
Article #178

BSD4.3 ls: sign extension bug

#178
From: Reg Quinton
Date: Wed, 25 Jul 1990 14:44
47 lines
2056 bytes
Christ! the things you discover when the accounting office gets
involved.  Our accounting office wanted to use all available gid/uid
numbers. We ran into 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.

Oh well, BSD 4.3 ls has been 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) */
Technical Details
Message-ID: <697@ria.ccs.uwo.ca>
Path: arc1-ca.pugleaf.net!utzoo!utgpu!watserv1!ria!reggers

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!utgpu!watserv1!ria!reggers
From: reggers@ria.ccs.uwo.ca (Reg Quinton)
Newsgroups: comp.bugs.4bsd
Subject: BSD4.3 ls: sign extension bug
Keywords: short, ushort, ls, bsd4.3, sign extension
Message-ID: <697@ria.ccs.uwo.ca>
Date: 25 Jul 90 14:44:18 GMT
Organization: Univ. Western Ontario, London Ont. CA
Lines: 48