]> git.cameronkatri.com Git - bsdgames-darwin.git/commitdiff
properly terminate after using strncpy().
authormrg <mrg@NetBSD.org>
Tue, 13 Apr 2021 01:50:46 +0000 (01:50 +0000)
committerCameron Katri <me@cameronkatri.com>
Tue, 13 Apr 2021 19:28:34 +0000 (15:28 -0400)
robots/score.c

index 5ae9083a81a4bb020dda57da6f05d0aabb3f8dac..91a2f38a0bea08b6457eef4ca45ccac787f4e069 100644 (file)
@@ -1,4 +1,4 @@
-/*     $NetBSD: score.c,v 1.23 2009/08/12 08:30:55 dholland Exp $      */
+/*     $NetBSD: score.c,v 1.24 2021/04/13 01:50:46 mrg 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.23 2009/08/12 08:30:55 dholland Exp $");
+__RCSID("$NetBSD: score.c,v 1.24 2021/04/13 01:50:46 mrg Exp $");
 #endif
 #endif /* not lint */
 
@@ -198,9 +198,10 @@ set_name(SCORE *scp)
        struct passwd *pp;
 
        if ((pp = getpwuid(scp->s_uid)) == NULL)
-               strncpy(scp->s_name, "???", MAXNAME);
+               strncpy(scp->s_name, "???", MAXNAME - 1);
        else
-               strncpy(scp->s_name, pp->pw_name, MAXNAME);
+               strncpy(scp->s_name, pp->pw_name, MAXNAME - 1);
+       scp->s_name[MAXNAME - 1] = '\0';
 }
 
 /*