summaryrefslogtreecommitdiffstats
path: root/battlestar
diff options
context:
space:
mode:
authorfox <fox@NetBSD.org>2020-02-05 20:11:54 +0000
committerfox <fox@NetBSD.org>2020-02-05 20:11:54 +0000
commitab68a55ee2f70a6069a6744bb9ab50507fd3fdc2 (patch)
tree1072040387538114d4db73b45497f2d197f822f2 /battlestar
parent0889d1a3707a23c5c00c085923944d126938fafd (diff)
downloadbsdgames-darwin-ab68a55ee2f70a6069a6744bb9ab50507fd3fdc2.tar.gz
bsdgames-darwin-ab68a55ee2f70a6069a6744bb9ab50507fd3fdc2.tar.zst
bsdgames-darwin-ab68a55ee2f70a6069a6744bb9ab50507fd3fdc2.zip
games/battlestar: Fix the -Werror=restrict warning.
Replace strcpy(1) with the safer snprintf(3) which guarantees NULL termination of strings. Error was reported when build.sh was run with MKLIBCSANITIZER=yes flag. Reviewed by: kamil@
Diffstat (limited to 'battlestar')
-rw-r--r--battlestar/parse.c12
1 files changed, 6 insertions, 6 deletions
diff --git a/battlestar/parse.c b/battlestar/parse.c
index 4b4b3bc6..605c4886 100644
--- a/battlestar/parse.c
+++ b/battlestar/parse.c
@@ -1,4 +1,4 @@
-/* $NetBSD: parse.c,v 1.15 2005/07/01 06:04:54 jmc Exp $ */
+/* $NetBSD: parse.c,v 1.16 2020/02/05 20:11:54 fox Exp $ */
/*
* Copyright (c) 1983, 1993
@@ -34,7 +34,7 @@
#if 0
static char sccsid[] = "@(#)parse.c 8.2 (Berkeley) 4/28/95";
#else
-__RCSID("$NetBSD: parse.c,v 1.15 2005/07/01 06:04:54 jmc Exp $");
+__RCSID("$NetBSD: parse.c,v 1.16 2020/02/05 20:11:54 fox Exp $");
#endif
#endif /* not lint */
@@ -120,7 +120,7 @@ parse(void)
for (i = n + 1; i < wordcount; i++) {
wordtype[i - 1] = wordtype[i];
wordvalue[i - 1] = wordvalue[i];
- strcpy(words[i - 1], words[i]);
+ snprintf(words[i - 1], WORDLEN, "%s", words[i]);
}
wordcount--;
}
@@ -140,7 +140,7 @@ parse(void)
for (i = n + 1; i < wordcount; i++) {
wordtype[i - 1] = wordtype[i];
wordvalue[i - 1] = wordvalue[i];
- strcpy(words[i - 1], words[i]);
+ snprintf(words[i - 1], WORDLEN, "%s", words[i]);
}
wordcount--;
}
@@ -164,7 +164,7 @@ parse(void)
wordtype[n + 1] = wordtype[n - 1];
wordtype[n - 1] = OBJECT;
strcpy(tmpword, words[n - 1]);
- strcpy(words[n - 1], words[n + 1]);
+ snprintf(words[n - 1], WORDLEN, "%s", words[n + 1]);
strcpy(words[n + 1], tmpword);
flag = 1;
}
@@ -177,7 +177,7 @@ parse(void)
for (i = n + 1; i < wordcount; i++) {
wordtype[i - 1] = wordtype[i + 1];
wordvalue[i - 1] = wordvalue[i + 1];
- strcpy(words[i - 1], words[i + 1]);
+ snprintf(words[i - 1], WORDLEN, "%s", words[i + 1]);
}
wordcount--;
wordcount--;