From a36884b3bd7197770867fbf85d0fad8bd4e3a52d Mon Sep 17 00:00:00 2001 From: kre Date: Sun, 26 Aug 2018 11:48:00 +0000 Subject: [PATCH] Validate that the configuration parameters that are supposed to be numeric are in fact numeric, and then have the awk script use them as awk numbers, rather than strings, so awk isn't doing string comparisons on numbers (where "1024" < 2). This has no effect with current configuratons, but would if anyone had ever attempted to configure a system with nsysent >= 1000 --- sys/kern/makesyscalls.sh | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/sys/kern/makesyscalls.sh b/sys/kern/makesyscalls.sh index bc02bc7a2584..545a169dd6d4 100644 --- a/sys/kern/makesyscalls.sh +++ b/sys/kern/makesyscalls.sh @@ -1,4 +1,4 @@ -# $NetBSD: makesyscalls.sh,v 1.170 2018/08/10 21:44:59 pgoyette Exp $ +# $NetBSD: makesyscalls.sh,v 1.171 2018/08/26 11:48:00 kre Exp $ # # Copyright (c) 1994, 1996, 2000 Christopher G. Demetriou # All rights reserved. @@ -78,6 +78,15 @@ case $1 in *) . ./$1;; esac +fail=false +case "${nsysent:-0}" in +*[!0-9]*) fail=true; printf >&2 '%s\n' "Non numeric value for nsysent";; +esac +case "${maxsysargs:-0}" in +*[!0-9]*) fail=true; printf >&2 '%s\n' "Non numeric value for maxsysargs";; +esac +$fail && exit 1 + # tmp files: sysdcl="sysent.dcl" sysprotos="sys.protos" @@ -172,7 +181,7 @@ BEGIN { if (!registertype) { registertype = \"register_t\" } - nsysent = \"$nsysent\" + nsysent = ${nsysent:-0} sysdcl = \"$sysdcl\" syscompat_pref = \"$syscompat_pref\" @@ -182,7 +191,7 @@ BEGIN { rumpprotos = \"$rumpprotos\" rumptypes = \"$rumptypes\" sys_nosys = \"$sys_nosys\" - maxsysargs = \"$maxsysargs\" + maxsysargs = ${maxsysargs:-8} rumpnoflags=\"$rumpnoflags\" rumpnosys=\"$rumpnosys\" rumpnomodule=\"$rumpnomodule\" @@ -1130,12 +1139,6 @@ END { maxsyscall = syscall - # XXX - # XXX The following comparisons with nsysent will produce - # XXX unexpected results if (for example) syscall has a - # XXX value of 900 and nsysent has a value of "1024". We - # XXX probably ought to make nsysent a numeric variable. - # XXX if (nsysent) { if (syscall > nsysent) { printf("%s: line %d: too many syscalls [%d > %d]\n", infile, NR, syscall, nsysent)