m4: import patch from OpenBSD
by espie@ ifelse is special, fix argv parsing to avoid segfault problem noticed by Matthew Green (netbsd), slightly different fix so that argc counting makes more sense. we might want to warn on wrong number of parameters later, but this is somewhat inconsistent depending on the builtin right now. okay millert@ Obtained from: OpenBSD
This commit is contained in:
parent
fdb905e20f
commit
e0f4e0415e
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=352068
@ -1,4 +1,4 @@
|
||||
/* $OpenBSD: eval.c,v 1.75 2017/06/15 13:48:42 bcallah Exp $ */
|
||||
/* $OpenBSD: eval.c,v 1.76 2017/10/23 15:21:19 espie Exp $ */
|
||||
/* $NetBSD: eval.c,v 1.7 1996/11/10 21:21:29 pk Exp $ */
|
||||
|
||||
/*-
|
||||
@ -201,7 +201,6 @@ expand_builtin(const char *argv[], int argc, int td)
|
||||
}
|
||||
|
||||
case IFELTYPE:
|
||||
if (argc > 4)
|
||||
doifelse(argv, argc);
|
||||
break;
|
||||
|
||||
@ -695,17 +694,17 @@ dotrace(const char *argv[], int argc, int on)
|
||||
static void
|
||||
doifelse(const char *argv[], int argc)
|
||||
{
|
||||
cycle {
|
||||
if (STREQ(argv[2], argv[3]))
|
||||
while (argc > 4) {
|
||||
if (STREQ(argv[2], argv[3])) {
|
||||
pbstr(argv[4]);
|
||||
else if (argc == 6)
|
||||
break;
|
||||
} else if (argc == 6) {
|
||||
pbstr(argv[5]);
|
||||
else if (argc > 6) {
|
||||
break;
|
||||
} else {
|
||||
argv += 3;
|
||||
argc -= 3;
|
||||
continue;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user