mirror of
https://git.haproxy.org/git/haproxy.git/
synced 2025-09-20 21:31:28 +02:00
BUG/MINOR: cfgparse: Add OOM check for calloc() in cfg_parse_listen()
This commit adds a missing out-of-memory (OOM) check after the call to `calloc()` in `cfg_parse_listen()`. If memory allocation fails, an alert is logged, error codes are set, and parsing is aborted to prevent undefined behavior. Co-authored-by: Christian Norbert Menges <christian.norbert.menges@sap.com>
This commit is contained in:
parent
c3e69cf065
commit
73f9a75894
@ -2029,6 +2029,12 @@ int cfg_parse_listen(const char *file, int linenum, char **args, int kwm)
|
|||||||
len += strlen(args[i]) + 1;
|
len += strlen(args[i]) + 1;
|
||||||
|
|
||||||
desc = d = calloc(1, len);
|
desc = d = calloc(1, len);
|
||||||
|
if (unlikely(!d)) {
|
||||||
|
ha_alert("parsing [%s:%d]: '%s %s' : memory allocation failed\n",
|
||||||
|
file, linenum, args[0], args[1]);
|
||||||
|
err_code |= ERR_ALERT | ERR_FATAL;
|
||||||
|
goto out;
|
||||||
|
}
|
||||||
|
|
||||||
d += snprintf(d, desc + len - d, "%s", args[2]);
|
d += snprintf(d, desc + len - d, "%s", args[2]);
|
||||||
for (i = 3; *args[i]; i++)
|
for (i = 3; *args[i]; i++)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user