[comp.bugs.sys5] Bug in ps -f

ccdn@levels.sait.edu.au (DAVID NEWALL) (10/18/88)

I have discovered a bug in System V Unixes.  Under certain circumstances,
ps -f displays "junk" in the login name field.  This bug exists on our NCR
Tower 32/600's which are running NCR OS 01.03.02 (Unix V.2) and also on my
Stride 440 (Unix/68 V.1).  This does not appear to be a problem in BSD4.2
- at least, the bug does not occur on our Sun 3/60's (SUNOS 3.2).

This bug occurs when a logged in user has a login name which is 8 characters
long (could be longer; I haven't checked), and when the entry in /etc/passwd
that follows that user's has a user number greater than 256.

The "junk" that is displayed is the user's login name followed by the next
user's user number mod 256 (as a character) followed by that (second) user's
login name.  Similarly for third and subsequent lines.

For example:

        $ who am i
        user1234
        $ tail -3 /etc/passwd
        user1234:likjlasdfSDF:100:100:User 1234:/usr/1234:/bin/sh
        user2345:89kkakkik2kH:321:100:User 2345:/usr/2345:/bin/sh
        user3456:jKLJD983.8Hs:322:100:User 3456:/usr/3456:/bin/sh
        $ ps -f
            UID   PID  PPID  C           TTY  TIME COMMAND
        user1234Auser2345Buser3456 14165     1  2 15:54:52   05  0:03 sh
        user1234Auser2345Buser3456 14166 14165  0 15:54:57   05  0:00 ps -f

David Newall                     Phone:  +61 8 343 3160
Unix Systems Programmer          Fax:    +61 8 349 6939
Academic Computing Service       E-mail: ccdn@levels.sait.oz.au
SA Institute of Technology       Post:   The Levels, South Australia, 5095

debra@alice.UUCP (Paul De Bra) (10/21/88)

In article <533@levels.sait.edu.au> ccdn@levels.sait.edu.au (DAVID NEWALL) writes:
>I have discovered a bug in System V Unixes.  Under certain circumstances,
>ps -f displays "junk" in the login name field.  This bug exists on our NCR
>...
>        $ ps -f
>            UID   PID  PPID  C           TTY  TIME COMMAND
>        user1234Auser2345Buser3456 14165     1  2 15:54:52   05  0:03 sh
>        user1234Auser2345Buser3456 14166 14165  0 15:54:57   05  0:00 ps -f
>

As far as I know this bug extremely old. The reason some programs show this
bug is that the internal representation of user names is done with an
8-character array. This means that usernames consisting of 8 characters are
not 0-terminated.

We worked around the problem by not allowing login names of more than 7
characters on any of our systems.

Paul.
-- 
-------------------------------------------------------------------------
|debra@research.att.com   | uunet!research!debra     | att!grumpy!debra |
-------------------------------------------------------------------------