From 9031b03b56fa36cfd9b09bb7f46b957effb6bd1c Mon Sep 17 00:00:00 2001 From: Markus Armbruster Date: Sat, 19 Jul 2008 22:35:23 -0400 Subject: [PATCH] Fix validation of threshold's threshold argument There were two checks meant to enforce positive numbers, both dating back to the earliest known versions of the code, and both wrong. The first one applied only to thresholds given with the command, not ones prompted for, and it incorrectly rejected numbers starting with + or prefixed by whitespace. Remove it. The second one failed to reject negative numbers when prefixed by whitespace. Fix. Fortunately, the update doesn't conjure up stuff to satisfy negative thresholds. --- src/lib/commands/thre.c | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/src/lib/commands/thre.c b/src/lib/commands/thre.c index 64c27a61b..b888aeecf 100644 --- a/src/lib/commands/thre.c +++ b/src/lib/commands/thre.c @@ -58,12 +58,7 @@ thre(void) if (!snxtsct(&nstr, player->argp[2])) return RET_SYN; type = ip->i_uid; - if (player->argp[3] && *player->argp[3] && - (*player->argp[3] < '0' || *player->argp[3] > '9')) { - pr("Threshold must be a number\n"); - return RET_SYN; - } - while (!player->aborted && nxtsct(&nstr, §)) { + while (nxtsct(&nstr, §)) { if (!player->owner) continue; val = sect.sct_dist[type]; @@ -76,12 +71,14 @@ thre(void) xyas(nstr.x, nstr.y, player->cnum), dchr[sect.sct_type].d_name); if ((p = getstarg(player->argp[3], prompt, buf)) == 0) - return RET_FAIL; + return RET_SYN; + if (!*p) + continue; if (!check_sect_ok(§)) return RET_FAIL; - if (*p == '\0' || *p == '-') - continue; thresh = atoi(p); + if (thresh < 0) + return RET_SYN; if (thresh > ITEM_MAX) thresh = ITEM_MAX; if ((val > 0) && (val == thresh)) { -- 2.43.0