From: Otto Moerbeek Date: Tue, 2 Jul 2024 10:22:29 +0000 (+0200) Subject: Avoid upos underflowing in match loop X-Git-Tag: rec-5.2.0-alpha1~203^2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=09462bda7f8da4e59307e0d6a7446d499c1da34c;p=thirdparty%2Fpdns.git Avoid upos underflowing in match loop --- diff --git a/ext/yahttp/yahttp/router.cpp b/ext/yahttp/yahttp/router.cpp index fdf23a45c5..5f6885a887 100644 --- a/ext/yahttp/yahttp/router.cpp +++ b/ext/yahttp/yahttp/router.cpp @@ -62,8 +62,15 @@ namespace YaHTTP { } nend = upos; params[pname] = funcptr::tie(nstart, nend); - - upos--; + if (upos > 0) { + upos--; + } + else { + // If upos is zero, do not decrement it and then increment at bottom of loop, this disturbs Coverity. + // Only increment rpos and continue loop + rpos++; + continue; + } } else if (route[rpos] != requrl.path[upos]) { break;