]> git.ipfire.org Git - thirdparty/squid.git/commit
Fix MAX_PKT{4,6}_SZ to account for icmpEchoData padding (#887)
authorSergio Durigan Junior <github@sergiodj.net>
Fri, 27 Aug 2021 10:37:50 +0000 (10:37 +0000)
committerSquid Anubis <squid-anubis@squid-cache.org>
Fri, 27 Aug 2021 10:37:53 +0000 (10:37 +0000)
commit2b9a2bba0f10e2aa9096883efc5b597a3a68bf5c
treef294eca4753774ce17461a74158e989d44004310
parentdc7bfd75163730fbcc0d2838f0ce87fe113f598c
Fix MAX_PKT{4,6}_SZ to account for icmpEchoData padding (#887)

The bug was exposed by GCC v11 on Ubuntu Impish:

    Icmp4.cc:116:11: error: array subscript icmpEchoData[0] is partly
        outside array bounds of char[282] [-Werror=array-bounds]
        echo->opcode = (unsigned char) opcode;

The array the compiler is talking about is the pkt buffer. That buffer
size (i.e. MAX_PKT4_SZ) was calculated under the faulty assumption that
a compiler cannot add padding after icmphdr (when doing "icmp+1") and/or
between icmpEchoData data members. When compiler padded, the old
MAX_PKT4_SZ math stopped working.

Same for ICMPv6.
CONTRIBUTORS
src/icmp/Icmp.h
src/icmp/Icmp4.cc
src/icmp/Icmp6.cc