From d37635b0ddebbe2ddeaafc38d59b7e340f883273 Mon Sep 17 00:00:00 2001 From: Ian Jackson Date: Tue, 22 Mar 2016 14:23:41 +0000 Subject: [PATCH] cgi-fcgi-interp: fix -M to actually work --- cprogs/cgi-fcgi-interp.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/cprogs/cgi-fcgi-interp.c b/cprogs/cgi-fcgi-interp.c index 1e368f0..9ebad2b 100644 --- a/cprogs/cgi-fcgi-interp.c +++ b/cprogs/cgi-fcgi-interp.c @@ -76,6 +76,7 @@ #include #include #include +#include #include #include @@ -114,12 +115,21 @@ static void of_help(const struct cmdinfo *ci, const char *val) { exit(0); } +static void of_iassign(const struct cmdinfo *ci, const char *val) { + long v; + char *ep; + errno= 0; v= strtol(val,&ep,10); + if (!*val || *ep || errno || vINT_MAX) + badusage("bad integer argument `%s' for --%s",val,ci->olong); + *ci->iassignto = v; +} + #define MAX_OPTS 5 static const struct cmdinfo cmdinfos[]= { { "help", 0, .call= of_help }, { 0, 'g', 1, .sassignto= &ident }, - { 0, 'M', 1, .iassignto= &numservers }, + { 0, 'M', 1, .call=of_iassign, .iassignto= &numservers }, { 0 } }; -- 2.30.2