BUG/MINOR: compression: Missing calloc return value check in comp_append_type/algo
A memory allocation failure happening in comp_append_type or
comp_append_algo called while parsing compression options would have
resulted in a crash. These functions are only called during
configuration parsing.
It was raised in GitHub issue #1233.
It could be backported to all stable branches.
(cherry picked from commit 6443bcc2e1f2e1e11af76ef460d8241f06223de8)
Signed-off-by: Christopher Faulet <cfaulet@haproxy.com>
(cherry picked from commit a3a8d50d992ab145e5c353cc36e8a787d3aead57)
Signed-off-by: Christopher Faulet <cfaulet@haproxy.com>
diff --git a/src/flt_http_comp.c b/src/flt_http_comp.c
index fb66947..cdb9f04 100644
--- a/src/flt_http_comp.c
+++ b/src/flt_http_comp.c
@@ -638,11 +638,17 @@
return -1;
}
while (*(args[cur_arg])) {
- if (comp_append_algo(comp, args[cur_arg]) < 0) {
- memprintf(err, "'%s' : '%s' is not a supported algorithm.\n",
- args[0], args[cur_arg]);
+ int retval = comp_append_algo(comp, args[cur_arg]);
+ if (retval) {
+ if (retval < 0)
+ memprintf(err, "'%s' : '%s' is not a supported algorithm.\n",
+ args[0], args[cur_arg]);
+ else
+ memprintf(err, "'%s' : out of memory while parsing algo '%s'.\n",
+ args[0], args[cur_arg]);
return -1;
}
+
if (proxy->comp->algos->init(&ctx, 9) == 0)
proxy->comp->algos->end(&ctx);
else {
@@ -664,7 +670,10 @@
return -1;
}
while (*(args[cur_arg])) {
- comp_append_type(comp, args[cur_arg]);
+ if (comp_append_type(comp, args[cur_arg])) {
+ memprintf(err, "'%s': out of memory.", args[0]);
+ return -1;
+ }
cur_arg++;
continue;
}