]> git.ipfire.org Git - thirdparty/haproxy.git/commit
BUILD: quic: fix dubious 0-byte overflow on qc_release_lost_pkts
authorAmaury Denoyelle <adenoyelle@haproxy.com>
Mon, 14 Nov 2022 10:41:34 +0000 (11:41 +0100)
committerAmaury Denoyelle <adenoyelle@haproxy.com>
Thu, 17 Nov 2022 09:34:47 +0000 (10:34 +0100)
commit3a72ba2aede63e49e53fe22b80e07c9d3c8f72e3
tree939d1e84ac5a645f649858420516cf01699fe525
parent1b662aabbfa32fb6ddeff4ff5f0e3031f12dafd3
BUILD: quic: fix dubious 0-byte overflow on qc_release_lost_pkts

With GCC 12.2.0 and O2 optimization activated, compiler reports the
following warning for qc_release_lost_pkts().

In function ‘quic_tx_packet_refdec’,
    inlined from ‘qc_release_lost_pkts.constprop’ at src/quic_conn.c:2056:3:
include/haproxy/atomic.h:320:41: error: ‘__atomic_sub_fetch_4’ writing 4 bytes into a region of size 0 overflows the destination [-Werror=stringop-overflow=]
  320 | #define HA_ATOMIC_SUB_FETCH(val, i)     __atomic_sub_fetch(val, i, __ATOMIC_SEQ_CST)
      |                                         ^~~~~~~~~~~~~~~~~~
include/haproxy/quic_conn.h:499:14: note: in expansion of macro ‘HA_ATOMIC_SUB_FETCH’
  499 |         if (!HA_ATOMIC_SUB_FETCH(&pkt->refcnt, 1)) {
      |              ^~~~~~~~~~~~~~~~~~~

GCC thinks that quic_tx_packet_refdec() can be called with a NULL
argument from qc_release_lost_pkts() with <oldest_lost> as arg.

This warning is a false positive as <oldest_lost> cannot be NULL in
qc_release_lost_pkts() at this stage. This is due to the previous check
to ensure that <pkts> list is not empty.

This warning is silenced by using ALREADY_CHECKED() macro.

This should be backported up to 2.6.

This should fix github issue #1852.
src/quic_conn.c