Module Name: src Committed By: christos Date: Sun Oct 22 23:01:34 UTC 2017
Modified Files: src/usr.bin/m4: eval.c Log Message: PR/52638: matthew green: missing argument check causes m4 to core in ifelse() To generate a diff of this commit: cvs rdiff -u -r1.24 -r1.25 src/usr.bin/m4/eval.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Modified files: Index: src/usr.bin/m4/eval.c diff -u src/usr.bin/m4/eval.c:1.24 src/usr.bin/m4/eval.c:1.25 --- src/usr.bin/m4/eval.c:1.24 Sat Jan 16 11:56:21 2016 +++ src/usr.bin/m4/eval.c Sun Oct 22 19:01:34 2017 @@ -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 @@ static void 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;