]> git.ipfire.org Git - thirdparty/haproxy.git/commit
BUG/MINOR: ncbuf: fix ncb_is_empty()
authorAmaury Denoyelle <adenoyelle@haproxy.com>
Tue, 17 May 2022 16:52:22 +0000 (18:52 +0200)
committerAmaury Denoyelle <adenoyelle@haproxy.com>
Wed, 18 May 2022 13:23:29 +0000 (15:23 +0200)
commitf6dbdc14448cbba57d62b51a7762d2d1b8024841
treee0142ced8f09c3bfc0f90da505247ced3009b079
parent82c51b561e82100aedbf88c957b2b70a1d83c122
BUG/MINOR: ncbuf: fix ncb_is_empty()

ncb_is_empty() was plainly incorrect as it directly dereferences the
memory to read offset blocks instead of ncb_read_off(). The result is
undefined.

Also, BUG_ON() statement is wrong when the buffer starts with a data
block. In this case, ncb_head() is not the first gap offset but instead
just random data. The calculated sum in BUG_ON() statement has thus no
meaning and may cause an abort. Adjust this by reorganizing the whole
function. Only the first data block size is read. If and only if not
nul, the first gap size is then checked.

ncb_is_full() has been rewritten to share the same model as
ncb_is_empty().
src/ncbuf.c