summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authornia <nia@NetBSD.org>2020-04-29 21:00:42 +0000
committernia <nia@NetBSD.org>2020-04-29 21:00:42 +0000
commit4260e713b7e2a1e451ebfe72e5e76d20b75f07c7 (patch)
tree6c6a03dfaa1a2c7bc2c5023ab585fbca1559dab6
parent35f9239da17d9e247372b31eff7d50efb738dded (diff)
downloadbsdgames-darwin-4260e713b7e2a1e451ebfe72e5e76d20b75f07c7.tar.gz
bsdgames-darwin-4260e713b7e2a1e451ebfe72e5e76d20b75f07c7.tar.zst
bsdgames-darwin-4260e713b7e2a1e451ebfe72e5e76d20b75f07c7.zip
unstr: Check that the input filename fits in the buffer.
-rw-r--r--fortune/unstr/unstr.c6
1 files changed, 3 insertions, 3 deletions
diff --git a/fortune/unstr/unstr.c b/fortune/unstr/unstr.c
index 6f5e8241..cadd35f4 100644
--- a/fortune/unstr/unstr.c
+++ b/fortune/unstr/unstr.c
@@ -1,4 +1,4 @@
-/* $NetBSD: unstr.c,v 1.14 2012/06/19 05:46:08 dholland Exp $ */
+/* $NetBSD: unstr.c,v 1.15 2020/04/29 21:00:42 nia Exp $ */
/*-
* Copyright (c) 1991, 1993
@@ -42,7 +42,7 @@ __COPYRIGHT("@(#) Copyright (c) 1991, 1993\
#if 0
static char sccsid[] = "@(#)unstr.c 8.1 (Berkeley) 5/31/93";
#else
-__RCSID("$NetBSD: unstr.c,v 1.14 2012/06/19 05:46:08 dholland Exp $");
+__RCSID("$NetBSD: unstr.c,v 1.15 2020/04/29 21:00:42 nia Exp $");
#endif
#endif /* not lint */
@@ -114,7 +114,7 @@ main(int ac __unused, char **av)
void
getargs(char *av[])
{
- if (!*++av) {
+ if (!*++av || (strlen(*av) + sizeof(".dat")) > sizeof(Datafile)) {
(void) fprintf(stderr, "usage: unstr datafile\n");
exit(1);
}