From: Eric Wong Date: Fri, 31 Oct 2025 02:45:02 +0000 (+0000) Subject: xap_helper: drop unnecessary check on split2argv result X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=7792516d06a042124a6d83f97253f1eac51bbcf4;p=thirdparty%2Fpublic-inbox.git xap_helper: drop unnecessary check on split2argv result Our split2argv will already abort on excessive or zero arguments, and it's impossible to for a `size_t' to evaluate to a negative value, anyways. While we're at it, explain it's safe to cast its return value to a signed int (typically 32-bit) since `req.argv' is a relatively small fixed value. --- diff --git a/lib/PublicInbox/xap_helper.h b/lib/PublicInbox/xap_helper.h index d582841c4..edc418926 100644 --- a/lib/PublicInbox/xap_helper.h +++ b/lib/PublicInbox/xap_helper.h @@ -945,6 +945,8 @@ static void recv_loop(void) // worker process loop continue; if (req.fp[1]) stderr_set(req.fp[1]); + + // MY_ARG_MAX limits the return value of SPLIT2ARGV req.argc = (int)SPLIT2ARGV(req.argv, rbuf, len); dispatch(&req); ERR_CLOSE(req.fp[0], 0); diff --git a/lib/PublicInbox/xh_cidx.h b/lib/PublicInbox/xh_cidx.h index 84686dff1..4212da788 100644 --- a/lib/PublicInbox/xh_cidx.h +++ b/lib/PublicInbox/xh_cidx.h @@ -267,7 +267,6 @@ static bool cmd_dump_roots(struct req *req) if (asize < est) ABORT("too many entries: %zu", est); drt.entries = (char **)xcalloc(asize, sizeof(char *)); size_t tot = split2argv(drt.entries, (char *)drt.mm_ptr, size, asize); - if (tot <= 0) return false; // split2argv already warned on error drt.root2id = root2id_init(); root2id_cm_resize(drt.root2id, est); for (size_t i = 0; i < tot; ) {