BUG/MINOR: http: Missing calloc return value check in parse_http_req_capture

A memory allocation failure happening in parse_http_req_capture while
processing a "len" keyword and allocating a cap_hdr structure would
have resulted in a crash. This function is only called during
configuration parsing.

It was raised in GitHub issue #1233.
It could be backported to all stable branches.
This commit is contained in:
Remi Tricot-Le Breton 2021-05-12 17:54:17 +02:00 committed by Christopher Faulet
parent 612b2c37be
commit a4bf8a059d

View File

@ -931,6 +931,11 @@ static enum act_parse_ret parse_http_req_capture(const char **args, int *orig_ar
cur_arg++;
hdr = calloc(1, sizeof(*hdr));
if (!hdr) {
memprintf(err, "out of memory");
release_sample_expr(expr);
return ACT_RET_PRS_ERR;
}
hdr->next = px->req_cap;
hdr->name = NULL; /* not a header capture */
hdr->namelen = 0;