Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/games/fortune/unstr unstr: Check that the input filename fit...



details:   https://anonhg.NetBSD.org/src/rev/daf3cc4d406b
branches:  trunk
changeset: 971609:daf3cc4d406b
user:      nia <nia%NetBSD.org@localhost>
date:      Wed Apr 29 21:00:42 2020 +0000

description:
unstr: Check that the input filename fits in the buffer.

diffstat:

 games/fortune/unstr/unstr.c |  6 +++---
 1 files changed, 3 insertions(+), 3 deletions(-)

diffs (27 lines):

diff -r 542202a0c3b5 -r daf3cc4d406b games/fortune/unstr/unstr.c
--- a/games/fortune/unstr/unstr.c       Wed Apr 29 20:45:05 2020 +0000
+++ b/games/fortune/unstr/unstr.c       Wed Apr 29 21:00:42 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.15 2020/04/29 21:00:42 nia 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.15 2020/04/29 21:00:42 nia 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