]> git.ipfire.org Git - thirdparty/squid.git/commitdiff
Fix -Wsign-compare on arm32 (#2432) auto master
authorFrancesco Chemolli <5175948+kinkie@users.noreply.github.com>
Tue, 2 Jun 2026 20:53:07 +0000 (20:53 +0000)
committerSquid Anubis <squid-anubis@squid-cache.org>
Thu, 4 Jun 2026 01:45:42 +0000 (01:45 +0000)
Due to ssize_t differences on 32/64 bit platforms, changes
to peerDigestSwapInMask in commit 556b91a8a7 cause
signedness comparison errors.
Refactor to be safe both on 32- and 64-bit platforms

src/peer_digest.cc

index 3546208e72ecd2b881986a1953d97a573d73197c..8660242d0fb46151aa1af8f2dae4de12d093881e 100644 (file)
@@ -559,7 +559,8 @@ peerDigestSwapInMask(void *data, char *buf, ssize_t size)
      * we need to do the copy ourselves!
      */
     Assure(size >= 0);
-    if (fetch->mask_offset + size > static_cast<ssize_t>(pd->cd->mask_size)) {
+    Assure(pd->cd->mask_size >= fetch->mask_offset);
+    if (static_cast<size_t>(size) > pd->cd->mask_size - fetch->mask_offset) {
         finishAndDeleteFetch(fetch, "peer digest mask data too large", true);
         return -1;
     }