From eff81569a5708e00ec3b6b2b6146771fbdd8e7d3 Mon Sep 17 00:00:00 2001 From: Theo de Raadt Date: Wed, 27 Feb 2008 17:19:35 +0000 Subject: fail nicely instead of crashing for format strings containing '*', without a matching argument following from Jukka Salmi --- usr.bin/awk/run.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'usr.bin/awk/run.c') 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)); -- cgit v1.2.3