]> git.ipfire.org Git - thirdparty/haproxy.git/commit
MINOR: cfgparse: load_cfg_in_mem: fix null ptr dereference reported by coverity
authorValentine Krasnobaeva <vkrasnobaeva@haproxy.com>
Thu, 8 Aug 2024 14:34:54 +0000 (16:34 +0200)
committerWilly Tarreau <w@1wt.eu>
Thu, 8 Aug 2024 17:54:12 +0000 (19:54 +0200)
commitda82f08055a74f2736b779893f9c970b5e862695
tree5403608f5d1c0cf48c3b720d24f739e0e7b51efc
parentfe5ddcc4901e3b43e58f5cf903c500a69d091b57
MINOR: cfgparse: load_cfg_in_mem: fix null ptr dereference reported by coverity

This helps to optimize a bit load_cfg_in_mem() and fixes the potential null ptr
dereference in fread() call. If (read_bytes + bytes_to_read) equals to initial
chunk_size (zero), realloc is never called, *cfg_content keeps its NULL value.

So, let's assure that initial number of bytes to read
(read_bytes + bytes_to_read) is stricly positive, when we enter into loop at
the first time.
src/cfgparse.c