From 4e46116954892c17ce95502f6740465ba3b3b3fc Mon Sep 17 00:00:00 2001 From: Baptiste Daroussin Date: Wed, 12 Apr 2023 18:13:09 +0200 Subject: [PATCH] listcontrol: simplify verifycation that param is digit only while here do not kill the program is the requested archive is not there but gracefully die --- src/listcontrol.c | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/src/listcontrol.c b/src/listcontrol.c index ce755b4f..c48d823a 100644 --- a/src/listcontrol.c +++ b/src/listcontrol.c @@ -623,18 +623,16 @@ permit: } } /* sanity check--is it all digits? */ - for(c = param; *c != '\0'; c++) { - if(!isdigit((int)*c)) { - errno = 0; - log_error(LOG_ARGS, "The get request contained" - " non-digits in index. Ignoring mail"); - return -1; - } + if (param[strspn(param, "0123456789")] != '\0') { + errno = 0; + log_error(LOG_ARGS, "The get request contained" + " non-digits in index. Ignoring mail"); + return -1; } xasprintf(&archivefilename, "%s/archive/%s", ml->dir, param); if(access(archivefilename, R_OK) < 0) { log_error(LOG_ARGS, "Unable to open archive file"); - exit(EXIT_FAILURE); + return -1; } log_oper(ml->fd, OPLOGFNAME, "%s got archive/%s", tll_front(*fromemails), archivefilename); -- 2.47.2