summaryrefslogtreecommitdiff
path: root/usr.bin/awk/run.c
diff options
context:
space:
mode:
authorTheo de Raadt <deraadt@cvs.openbsd.org>2008-02-27 17:19:35 +0000
committerTheo de Raadt <deraadt@cvs.openbsd.org>2008-02-27 17:19:35 +0000
commiteff81569a5708e00ec3b6b2b6146771fbdd8e7d3 (patch)
tree0c3608a3be260f9fce09659feeaac88818342d2f /usr.bin/awk/run.c
parent1247a919a0503750f124a67be925b45f408dfc61 (diff)
fail nicely instead of crashing for format strings containing '*',
without a matching argument following from Jukka Salmi
Diffstat (limited to 'usr.bin/awk/run.c')
-rw-r--r--usr.bin/awk/run.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/usr.bin/awk/run.c b/usr.bin/awk/run.c
index a70dabf278c..cdce6a398e3 100644
--- a/usr.bin/awk/run.c
+++ b/usr.bin/awk/run.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: run.c,v 1.26 2004/12/30 02:08:35 millert Exp $ */
+/* $OpenBSD: run.c,v 1.27 2008/02/27 17:19:34 deraadt Exp $ */
/****************************************************************
Copyright (C) Lucent Technologies 1997
All Rights Reserved
@@ -843,6 +843,8 @@ int format(char **pbuf, int *pbufsize, const char *s, Node *a) /* printf-like co
if (isalpha((uschar)*s) && *s != 'l' && *s != 'h' && *s != 'L')
break; /* the ansi panoply */
if (*s == '*') {
+ if (a == NULL)
+ FATAL("not enough args in printf(%s)", os);
x = execute(a);
a = a->nnext;
snprintf(t-1, fmt + fmtsz - (t-1), "%d", fmtwd=(int) getfval(x));