]> git.ipfire.org Git - thirdparty/mlmmj.git/commitdiff
listcontrol: simplify verifycation that param is digit only
authorBaptiste Daroussin <bapt@FreeBSD.org>
Wed, 12 Apr 2023 16:13:09 +0000 (18:13 +0200)
committerBaptiste Daroussin <bapt@FreeBSD.org>
Wed, 12 Apr 2023 16:13:09 +0000 (18:13 +0200)
while here do not kill the program is the requested archive is not
there but gracefully die

src/listcontrol.c

index ce755b4f8b71f8085ea8ce2f1baeb271e7bbb953..c48d823a0cb3c38fb36b5b8e3e1a6e8ee8f8d950 100644 (file)
@@ -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);