]> git.ipfire.org Git - thirdparty/haproxy.git/commit
MINOR: log/cbor: _lf_cbor_encode_byte() explicitly requires non-NULL ctx
authorAurelien DARRAGON <adarragon@haproxy.com>
Mon, 29 Apr 2024 07:46:24 +0000 (09:46 +0200)
committerAurelien DARRAGON <adarragon@haproxy.com>
Mon, 29 Apr 2024 12:47:37 +0000 (14:47 +0200)
commit9bdea51d7e2e5b2d3a0066190fea5c0a2c0cbb6b
treef177a06ad068ffe6c04d1991b59d398fe945ab94
parent0e2aea8224e42f8730a7786be7ce851abb54ab75
MINOR: log/cbor: _lf_cbor_encode_byte() explicitly requires non-NULL ctx

As shown in GH #2550, Coverity is tempted to think that NULL-dereference
can occur in _lf_cbor_encode_byte() due to user-ctx being dereferenced
from cbor_ctx, while coverity thinks that cbor_ctx may be NULL.

In practise this cannot happen, because _lf_cbor_encode_byte() is
only leveraged through a function pointer that is set in conjunction with
the function pointer ctx (which ain't NULL). All this logic is done inside
lf_buildctx_prepare() when LOG_OPT_ENCODE_CBOR is set.

Since coverity doesn't seem to understand the logic properly, then it
might as well confuse humans, so let's make it clear in
_lf_cbor_encode_byte() that we expect non-NULL ctx by adding a BUG_ON()
src/log.c