summaryrefslogtreecommitdiff
path: root/games/gomoku/main.c
diff options
context:
space:
mode:
authorPaul Janzen <pjanzen@cvs.openbsd.org>2001-02-17 22:38:07 +0000
committerPaul Janzen <pjanzen@cvs.openbsd.org>2001-02-17 22:38:07 +0000
commitabf82807fee14c388da59444decd320a870b1648 (patch)
treeb60dcf97cfd66b1c1201ad8a7dee68c2bd26d837 /games/gomoku/main.c
parent541cb262e526b7415bb94badb53deeb08c633a4d (diff)
Handle long usernames better
Diffstat (limited to 'games/gomoku/main.c')
-rw-r--r--games/gomoku/main.c16
1 files changed, 10 insertions, 6 deletions
diff --git a/games/gomoku/main.c b/games/gomoku/main.c
index 6af6bd773e0..4014ca7ae3a 100644
--- a/games/gomoku/main.c
+++ b/games/gomoku/main.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: main.c,v 1.8 1998/03/26 21:16:49 pjanzen Exp $ */
+/* $OpenBSD: main.c,v 1.9 2001/02/17 22:38:06 pjanzen Exp $ */
/*
* Copyright (c) 1994
* The Regents of the University of California. All rights reserved.
@@ -45,11 +45,11 @@ static char copyright[] =
#if 0
static char sccsid[] = "@(#)main.c 8.4 (Berkeley) 5/4/95";
#else
-static char rcsid[] = "$OpenBSD: main.c,v 1.8 1998/03/26 21:16:49 pjanzen Exp $";
+static char rcsid[] = "$OpenBSD: main.c,v 1.9 2001/02/17 22:38:06 pjanzen Exp $";
#endif
#endif /* not lint */
-#include "gomoku.h"
+#include <sys/param.h>
#include <curses.h>
#include <err.h>
#include <signal.h>
@@ -57,6 +57,8 @@ static char rcsid[] = "$OpenBSD: main.c,v 1.8 1998/03/26 21:16:49 pjanzen Exp $"
#include <string.h>
#include <unistd.h>
+#include "gomoku.h"
+
#define USER 0 /* get input from standard input */
#define PROGRAM 1 /* get input from program */
#define INPUTF 2 /* get input from a file */
@@ -80,7 +82,7 @@ int movelog[BSZ * BSZ]; /* log of all the moves */
int movenum; /* current move number */
char *plyr[2]; /* who's who */
-static char you[9] = "you\0\0\0\0\0\0"; /* username */
+static char you[MAXLOGNAME]; /* username */
int
main(argc, argv)
@@ -106,8 +108,10 @@ main(argc, argv)
else
prog = argv[0];
- if ((tmpname = getlogin()) != 0)
- strncpy(you,tmpname,8);
+ if ((tmpname = getlogin()) != NULL)
+ strlcpy(you, tmpname, sizeof(you));
+ else
+ strlcpy(you, "you", sizeof(you));
while ((ch = getopt(argc, argv, "bcdD:hu")) != -1) {
switch (ch) {