Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/netbsd-9]: src/games/fortune Pull up following revision(s) (requested by...
details: https://anonhg.NetBSD.org/src/rev/6f956c71e612
branches: netbsd-9
changeset: 963848:6f956c71e612
user: martin <martin%NetBSD.org@localhost>
date: Thu Apr 30 16:19:29 2020 +0000
description:
Pull up following revision(s) (requested by nia in ticket #879):
games/fortune/strfile/strfile.c: revision 1.39
games/fortune/unstr/unstr.c: revision 1.15
strfile: Check that input/output filenames don't exceed the buffer size
unstr: Check that the input filename fits in the buffer.
diffstat:
games/fortune/strfile/strfile.c | 20 ++++++++++++++++----
games/fortune/unstr/unstr.c | 6 +++---
2 files changed, 19 insertions(+), 7 deletions(-)
diffs (81 lines):
diff -r ceaa14ab449f -r 6f956c71e612 games/fortune/strfile/strfile.c
--- a/games/fortune/strfile/strfile.c Thu Apr 30 16:17:04 2020 +0000
+++ b/games/fortune/strfile/strfile.c Thu Apr 30 16:19:29 2020 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: strfile.c,v 1.38 2013/09/19 00:34:00 uwe Exp $ */
+/* $NetBSD: strfile.c,v 1.38.28.1 2020/04/30 16:19:29 martin Exp $ */
/*-
* Copyright (c) 1989, 1993
@@ -47,7 +47,7 @@
#if 0
static char sccsid[] = "@(#)strfile.c 8.1 (Berkeley) 5/31/93";
#else
-__RCSID("$NetBSD: strfile.c,v 1.38 2013/09/19 00:34:00 uwe Exp $");
+__RCSID("$NetBSD: strfile.c,v 1.38.28.1 2020/04/30 16:19:29 martin Exp $");
#endif
#endif /* not lint */
#endif /* __NetBSD__ */
@@ -267,6 +267,7 @@
int ch;
extern int optind;
extern char *optarg;
+ size_t len;
while ((ch = getopt(argc, argv, "c:iorsx")) != -1)
switch(ch) {
@@ -300,14 +301,25 @@
if (*argv) {
Infile = *argv;
- if (*++argv)
- (void) strcpy(Outfile, *argv);
+ if (*++argv) {
+ len = strlen(*argv);
+ if (len >= sizeof(Outfile)) {
+ puts("Bad output filename");
+ usage();
+ }
+ (void) memcpy(Outfile, *argv, len + 1);
+ }
}
if (!Infile) {
puts("No input file name");
usage();
}
if (*Outfile == '\0') {
+ len = strlen(Infile) + sizeof(".dat");
+ if (len > sizeof(Outfile)) {
+ puts("Bad input filename");
+ usage();
+ }
(void) strcpy(Outfile, Infile);
(void) strcat(Outfile, ".dat");
}
diff -r ceaa14ab449f -r 6f956c71e612 games/fortune/unstr/unstr.c
--- a/games/fortune/unstr/unstr.c Thu Apr 30 16:17:04 2020 +0000
+++ b/games/fortune/unstr/unstr.c Thu Apr 30 16:19:29 2020 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: unstr.c,v 1.14 2012/06/19 05:46:08 dholland Exp $ */
+/* $NetBSD: unstr.c,v 1.14.34.1 2020/04/30 16:19:29 martin Exp $ */
/*-
* Copyright (c) 1991, 1993
@@ -42,7 +42,7 @@
#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.14.34.1 2020/04/30 16:19:29 martin Exp $");
#endif
#endif /* not lint */
@@ -114,7 +114,7 @@
void
getargs(char *av[])
{
- if (!*++av) {
+ if (!*++av || (strlen(*av) + sizeof(".dat")) > sizeof(Datafile)) {
(void) fprintf(stderr, "usage: unstr datafile\n");
exit(1);
}
Home |
Main Index |
Thread Index |
Old Index