Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Posting-Version: version B 2.10.2 9/18/84 SMI; site sun.uucp Path: utzoo!linus!decvax!decwrl!sun!guy From: guy@sun.uucp (Guy Harris) Newsgroups: net.bugs.usg Subject: Re: SVR2.2 "ls" bug Message-ID: <2498@sun.uucp> Date: Sat, 27-Jul-85 05:44:53 EDT Article-I.D.: sun.2498 Posted: Sat Jul 27 05:44:53 1985 Date-Received: Sun, 28-Jul-85 06:20:11 EDT References: <595@mtuxn.UUCP> Organization: Sun Microsystems, Inc. Lines: 21 > 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