mirror of
https://git.haproxy.org/git/haproxy.git/
synced 2025-11-29 06:40:59 +01:00
CLEANUP: tcpcheck: remove the only occurrence of sprintf() in the code
There's a single sprintf() in the whole code, in the "option smtpchk" parser in tcpcheck.c. Let's turn it to a safer snprintf().
This commit is contained in:
parent
22450af22a
commit
a0fa577070
@ -4262,9 +4262,10 @@ int proxy_parse_smtpchk_opt(char **args, int cur_arg, struct proxy *curpx, const
|
|||||||
if (*args[cur_arg] && *args[cur_arg+1] &&
|
if (*args[cur_arg] && *args[cur_arg+1] &&
|
||||||
(strcmp(args[cur_arg], "EHLO") == 0 || strcmp(args[cur_arg], "HELO") == 0)) {
|
(strcmp(args[cur_arg], "EHLO") == 0 || strcmp(args[cur_arg], "HELO") == 0)) {
|
||||||
/* <EHLO|HELO> + space (1) + <host> + null byte (1) */
|
/* <EHLO|HELO> + space (1) + <host> + null byte (1) */
|
||||||
cmd = calloc(strlen(args[cur_arg]) + 1 + strlen(args[cur_arg+1]) + 1, sizeof(*cmd));
|
size_t len = strlen(args[cur_arg]) + 1 + strlen(args[cur_arg+1]) + 1;
|
||||||
|
cmd = calloc(len, 1);
|
||||||
if (cmd)
|
if (cmd)
|
||||||
sprintf(cmd, "%s %s", args[cur_arg], args[cur_arg+1]);
|
snprintf(cmd, len, "%s %s", args[cur_arg], args[cur_arg+1]);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
/* this just hits the default for now, but you could potentially expand it to allow for other stuff
|
/* this just hits the default for now, but you could potentially expand it to allow for other stuff
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user