mirror of
https://git.haproxy.org/git/haproxy.git/
synced 2025-09-20 13:21:29 +02:00
MINOR: acme: check acme-vars allocation during escaping
Handle allocation properly during acme-vars parsing. Check if we have a allocation failure in both the malloc and the realloc and emits an error if that's the case.
This commit is contained in:
parent
92c31a6fb7
commit
34cdc5e191
15
src/acme.c
15
src/acme.c
@ -455,20 +455,29 @@ static int cfg_parse_acme_kws(char **args, int section_type, struct proxy *curpx
|
|||||||
goto out;
|
goto out;
|
||||||
|
|
||||||
len = strlen(src);
|
len = strlen(src);
|
||||||
dst = realloc(dst, len + 1);
|
dst = malloc(len + 1);
|
||||||
|
if (!dst)
|
||||||
|
goto vars_end;
|
||||||
|
|
||||||
/* escape the " character */
|
/* escape the " character */
|
||||||
while (*src) {
|
while (*src) {
|
||||||
if (*src == '"') {
|
if (*src == '"') {
|
||||||
|
char *dst2 = NULL;
|
||||||
|
|
||||||
len++;
|
len++;
|
||||||
dst = realloc(dst, len + 1);
|
dst2 = realloc(dst, len + 1);
|
||||||
|
if (!dst2) {
|
||||||
|
ha_free(&dst);
|
||||||
|
goto vars_end;
|
||||||
|
}
|
||||||
|
dst = dst2;
|
||||||
dst[i++] = '\\'; /* add escaping */
|
dst[i++] = '\\'; /* add escaping */
|
||||||
}
|
}
|
||||||
dst[i++] = *src;
|
dst[i++] = *src;
|
||||||
src++;
|
src++;
|
||||||
}
|
}
|
||||||
dst[i] = '\0';
|
dst[i] = '\0';
|
||||||
|
vars_end:
|
||||||
cur_acme->vars = dst;
|
cur_acme->vars = dst;
|
||||||
if (!cur_acme->vars) {
|
if (!cur_acme->vars) {
|
||||||
err_code |= ERR_ALERT | ERR_FATAL;
|
err_code |= ERR_ALERT | ERR_FATAL;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user