[net.bugs.usg] SVR2.2 "ls" bug

rubin@mtuxn.UUCP (M.RUBIN) (07/26/85)

Bug found on a 3B2 running System V release 2.2 (I don't have any other
SVR2.2 machines to compare with):

When using any of the multi-column modes of "ls" (e.g. -x or -C), the column
spacing is normally (length of longest filename in listing + 2).  However,
if any of the filenames being listed are the maximum length for a filename
(14 chars), the column spacing suddenly becomes 44 chars.  On an 80-char-wide
terminal this means a one-column listing.

Probable cause: there are two different constants for maximum widths of
things, and the programmer used the wrong one someplace.  I don't have
source to fix it.

guy@sun.uucp (Guy Harris) (07/27/85)

> When using any of the multi-column modes of "ls" (e.g. -x or -C), the column
> spacing is normally (length of longest filename in listing + 2).  However,
> if any of the filenames being listed are the maximum length for a filename
> (14 chars), the column spacing suddenly becomes 44 chars.

> Probable cause: there are two different constants for maximum widths of
> things, and the programmer used the wrong one someplace.  I don't have
> source to fix it.

Nope.  The problem is that the code in "readdir" that reads directory
entries and computes the maximum length of all the names it's seen doesn't
realize that directory entries are NOT necessarily terminated with a NUL
character.  As such, if the file's name is exactly DIRSIZ characters, the
"strlen" goes past the end and keeps going until (if you're lucky) it
encounters a zero byte.

Note that if S5 as distributed had the directory library, and used it, this
bug would go away by magic; the directory library makes sure the file name
is NUL-terminated.

	Guy Harris

larry@kitty.UUCP (Larry Lippman) (07/28/85)

> Bug found on a 3B2 running System V release 2.2 (I don't have any other
> SVR2.2 machines to compare with):
> 
> When using any of the multi-column modes of "ls" (e.g. -x or -C), the column
> spacing is normally (length of longest filename in listing + 2).  However,
> if any of the filenames being listed are the maximum length for a filename
> (14 chars), the column spacing suddenly becomes 44 chars.  On an 80-char-wide
> terminal this means a one-column listing.

Yup.  Same problem.  Same machine.  Same UNIX release.

I do wish this was my most serious Release 2.2 bug, however...

	Larry Lippman
	Recognition Research Corp.
	Clarence, New York
	UUCP	{decvax,dual,rocksanne,rocksvax,watmath}!sunybcs!kitty!larry
		{rice,shell}!baylor!kitty!larry
		syr!buf!kitty!larry
	VOICE	716/741-9185
	TELEX	{via WUI} 69-71461 answerback: ELGECOMCLR

	"Have you hugged your cat today?"