BUG/MINOR: compression: possible NULL dereferences in comp_prepare_compress_request()
authorAurelien DARRAGON <adarragon@haproxy.com>
Tue, 28 Nov 2023 14:47:25 +0000 (15:47 +0100)
committerChristopher Faulet <cfaulet@haproxy.com>
Wed, 29 Nov 2023 07:59:27 +0000 (08:59 +0100)
commitd3cbd369506e60d55354dd310d098ff6fd739bf4
treea911ea92d5ff36de9502bc626d28289604553f97
parent2f2cb6d08253f036557036d22df41be155e2f091
BUG/MINOR: compression: possible NULL dereferences in comp_prepare_compress_request()

This bug was introduced in ead43fe4f2 ("MEDIUM: compression: Make it so
we can compress requests as well.")

2 cases where not properly handled, resulting in 2 possible NULL
dereferences leading to crashes in the function at runtime:
 - when the backend didn't define any compression options so its comp
   pointer is NULL (ie: if only the frontend defines some comp options)
 - when both the frontend and the backend didn't set a compression algo
   but at least one of the two defined some other comp options (comp
   pointer set)

For the first case, we added the missing checks to make sure we don't
read ->comp pointer if it is NULL.
For the second case, we properly return from the function if no
compression algo is defined, because there is no default value that could
be used as a fallback.

This should be backported to 2.8.
src/flt_http_comp.c