Source-Changes-HG archive

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

[src/trunk]: src/usr.bin/m4 PR/52638: matthew green: missing argument check c...



details:   https://anonhg.NetBSD.org/src/rev/91b764a3c0b4
branches:  trunk
changeset: 356987:91b764a3c0b4
user:      christos <christos%NetBSD.org@localhost>
date:      Sun Oct 22 23:01:34 2017 +0000

description:
PR/52638: matthew green: missing argument check causes m4 to core in ifelse()

diffstat:

 usr.bin/m4/eval.c |  10 ++++++----
 1 files changed, 6 insertions(+), 4 deletions(-)

diffs (33 lines):

diff -r 0454c2b407bc -r 91b764a3c0b4 usr.bin/m4/eval.c
--- a/usr.bin/m4/eval.c Sun Oct 22 20:35:32 2017 +0000
+++ b/usr.bin/m4/eval.c Sun Oct 22 23:01:34 2017 +0000
@@ -1,5 +1,5 @@
 /*     $OpenBSD: eval.c,v 1.66 2008/08/21 21:01:47 espie Exp $ */
-/*     $NetBSD: eval.c,v 1.24 2016/01/16 16:56:21 christos Exp $       */
+/*     $NetBSD: eval.c,v 1.25 2017/10/22 23:01:34 christos Exp $       */
 
 /*
  * Copyright (c) 1989, 1993
@@ -42,7 +42,7 @@
 #include "nbtool_config.h"
 #endif
 #include <sys/cdefs.h>
-__RCSID("$NetBSD: eval.c,v 1.24 2016/01/16 16:56:21 christos Exp $");
+__RCSID("$NetBSD: eval.c,v 1.25 2017/10/22 23:01:34 christos Exp $");
 
 #include <sys/types.h>
 #include <ctype.h>
@@ -698,9 +698,11 @@
 doifelse(const char *argv[], int argc)
 {
        cycle {
-               if (STREQ(argv[2], argv[3]))
+               if (argc < 5)
+                       m4errx(1, "wrong number of args for ifelse");
+               if (STREQ(argv[2], argv[3])) {
                        pbstr(argv[4]);
-               else if (argc == 6)
+               } else if (argc == 6)
                        pbstr(argv[5]);
                else if (argc > 6) {
                        argv += 3;



Home | Main Index | Thread Index | Old Index