mirror of
https://git.haproxy.org/git/haproxy.git/
synced 2025-09-22 06:11:32 +02:00
BUG/MINOR: ssl: fix a trash buffer leak in some error cases
Fix a trash buffer leak when we can't take the lock of the ckch, or when "set ssl cert" is wrongly used. The bug was mentionned in this thread: https://www.mail-archive.com/haproxy@formilux.org/msg37539.html The bug was introduced by commit bc6ca7c ("MINOR: ssl/cli: rework 'set ssl cert' as 'set/commit'"). Must be backported in 2.1.
This commit is contained in:
parent
0041741ef7
commit
e5ff4addb2
@ -1552,9 +1552,6 @@ static int cli_parse_set_cert(char **args, char *payload, struct appctx *appctx,
|
|||||||
if (!cli_has_level(appctx, ACCESS_LVL_ADMIN))
|
if (!cli_has_level(appctx, ACCESS_LVL_ADMIN))
|
||||||
return 1;
|
return 1;
|
||||||
|
|
||||||
if ((buf = alloc_trash_chunk()) == NULL)
|
|
||||||
return cli_err(appctx, "Can't allocate memory\n");
|
|
||||||
|
|
||||||
if (!*args[3] || !payload)
|
if (!*args[3] || !payload)
|
||||||
return cli_err(appctx, "'set ssl cert expects a filename and a certificate as a payload\n");
|
return cli_err(appctx, "'set ssl cert expects a filename and a certificate as a payload\n");
|
||||||
|
|
||||||
@ -1563,6 +1560,9 @@ static int cli_parse_set_cert(char **args, char *payload, struct appctx *appctx,
|
|||||||
if (HA_SPIN_TRYLOCK(CKCH_LOCK, &ckch_lock))
|
if (HA_SPIN_TRYLOCK(CKCH_LOCK, &ckch_lock))
|
||||||
return cli_err(appctx, "Can't update the certificate!\nOperations on certificates are currently locked!\n");
|
return cli_err(appctx, "Can't update the certificate!\nOperations on certificates are currently locked!\n");
|
||||||
|
|
||||||
|
if ((buf = alloc_trash_chunk()) == NULL)
|
||||||
|
return cli_err(appctx, "Can't allocate memory\n");
|
||||||
|
|
||||||
if (!chunk_strcpy(buf, args[3])) {
|
if (!chunk_strcpy(buf, args[3])) {
|
||||||
memprintf(&err, "%sCan't allocate memory\n", err ? err : "");
|
memprintf(&err, "%sCan't allocate memory\n", err ? err : "");
|
||||||
errcode |= ERR_ALERT | ERR_FATAL;
|
errcode |= ERR_ALERT | ERR_FATAL;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user