BUG/MINOR: hlua_fcn: potentially unsafe stktable_data_ptr usage
authorAurelien DARRAGON <adarragon@haproxy.com>
Tue, 22 Aug 2023 09:03:06 +0000 (11:03 +0200)
committerWilliam Lallemand <wlallemand@haproxy.org>
Fri, 25 Aug 2023 09:52:43 +0000 (11:52 +0200)
commitee1891ccbe1d0e614985d30b83036567bcc3784e
treeae68d424cf4cf9a6dc50f934c019d04f10496b0a
parent28e94c619260b4aca1de1213464334bd9b5418c9
BUG/MINOR: hlua_fcn: potentially unsafe stktable_data_ptr usage

As reported by Coverity in GH #2253, stktable_data_ptr() usage in
hlua_stktable_dump() func is potentially unsafe because
stktable_data_ptr() may return NULL and the returned value is
dereferenced as-is without precautions.

In practise, this should not happen because some error checking was
already performed prior to calling stktable_data_ptr(). But since we're
using the safe stktable_data_ptr() function, all the error checking is
already done within the function, thus all we need to do is check ptr
against NULL instead to protect against NULL dereferences.

This should be backported in every stable versions.
src/hlua_fcn.c