diff options
author | abs <abs@NetBSD.org> | 2006-03-17 23:11:47 +0000 |
---|---|---|
committer | abs <abs@NetBSD.org> | 2006-03-17 23:11:47 +0000 |
commit | 90015c74726f52760b0a78753b8d298bf9411018 (patch) | |
tree | 3e3a96bce7ea63f556aa2746c11c00348540a8f3 /robots | |
parent | 5eb45781ef17a15eed8ec8ecf03e20d8ad7f69cc (diff) | |
download | bsdgames-darwin-90015c74726f52760b0a78753b8d298bf9411018.tar.gz bsdgames-darwin-90015c74726f52760b0a78753b8d298bf9411018.tar.zst bsdgames-darwin-90015c74726f52760b0a78753b8d298bf9411018.zip |
If getpwuid() returns null, its not usually a good idea to dereference
that to try to assign a default value. Just copy the default value into
the final destination.
Addresses Coverty CID 925
Diffstat (limited to 'robots')
-rw-r--r-- | robots/score.c | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/robots/score.c b/robots/score.c index 4c87bd4e..62709435 100644 --- a/robots/score.c +++ b/robots/score.c @@ -1,4 +1,4 @@ -/* $NetBSD: score.c,v 1.17 2004/01/27 20:30:30 jsm Exp $ */ +/* $NetBSD: score.c,v 1.18 2006/03/17 23:11:47 abs Exp $ */ /* * Copyright (c) 1980, 1993 @@ -34,7 +34,7 @@ #if 0 static char sccsid[] = "@(#)score.c 8.1 (Berkeley) 5/31/93"; #else -__RCSID("$NetBSD: score.c,v 1.17 2004/01/27 20:30:30 jsm Exp $"); +__RCSID("$NetBSD: score.c,v 1.18 2006/03/17 23:11:47 abs Exp $"); #endif #endif /* not lint */ @@ -193,11 +193,11 @@ set_name(scp) SCORE *scp; { PASSWD *pp; - static char unknown[] = "???"; if ((pp = getpwuid(scp->s_uid)) == NULL) - pp->pw_name = unknown; - strncpy(scp->s_name, pp->pw_name, MAXNAME); + strncpy(scp->s_name, "???", MAXNAME); + else + strncpy(scp->s_name, pp->pw_name, MAXNAME); } /* |