Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/usr.bin/who How did this bug survive for so long? 'who am i'...



details:   https://anonhg.NetBSD.org/src/rev/8ec8f3ce5930
branches:  trunk
changeset: 474730:8ec8f3ce5930
user:      christos <christos%NetBSD.org@localhost>
date:      Sat Jul 17 16:41:44 1999 +0000

description:
How did this bug survive for so long? 'who am i' was busted because
it checked for valid utmp entries with usr.ut_name != NULL which can
never happen ofcourse, instead of usr.ut_name[0] != '\0'

diffstat:

 usr.bin/who/who.c |  7 ++++---
 1 files changed, 4 insertions(+), 3 deletions(-)

diffs (28 lines):

diff -r 906e05f98e49 -r 8ec8f3ce5930 usr.bin/who/who.c
--- a/usr.bin/who/who.c Sat Jul 17 14:12:21 1999 +0000
+++ b/usr.bin/who/who.c Sat Jul 17 16:41:44 1999 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: who.c,v 1.7 1998/12/20 14:53:24 christos Exp $ */
+/*     $NetBSD: who.c,v 1.8 1999/07/17 16:41:44 christos Exp $ */
 
 /*
  * Copyright (c) 1989, 1993
@@ -47,7 +47,7 @@
 #if 0
 static char sccsid[] = "@(#)who.c      8.1 (Berkeley) 6/6/93";
 #endif
-__RCSID("$NetBSD: who.c,v 1.7 1998/12/20 14:53:24 christos Exp $");
+__RCSID("$NetBSD: who.c,v 1.8 1999/07/17 16:41:44 christos Exp $");
 #endif /* not lint */
 
 #include <sys/types.h>
@@ -165,7 +165,8 @@
                if ((t = strrchr(p, '/')) != NULL)
                        p = t + 1;
                while (fread((char *)&usr, sizeof(usr), 1, ufp) == 1)
-                       if (usr.ut_name && !strcmp(usr.ut_line, p)) {
+                       if (usr.ut_name[0] != '\0' &&
+                           !strcmp(usr.ut_line, p)) {
                                output(&usr);
                                return;
                        }



Home | Main Index | Thread Index | Old Index