mirror of
https://git.haproxy.org/git/haproxy.git/
synced 2025-09-22 22:31:28 +02:00
BUILD/MEDIUM: cfgparse: get rid of sprintf()
A few occurrences of sprintf() were causing harmless warnings on OpenBSD : src/cfgparse.o(.text+0x259e): In function `cfg_parse_global': src/cfgparse.c:1044: warning: sprintf() is often misused, please use snprintf() These ones were easy to get rid of, so better do it.
This commit is contained in:
parent
761b3d557e
commit
348acfe272
@ -1041,9 +1041,9 @@ int cfg_parse_global(const char *file, int linenum, char **args, int kwm)
|
|||||||
|
|
||||||
global.desc = d = (char *)calloc(1, len);
|
global.desc = d = (char *)calloc(1, len);
|
||||||
|
|
||||||
d += sprintf(d, "%s", args[1]);
|
d += snprintf(d, global.desc + len - d, "%s", args[1]);
|
||||||
for (i = 2; *args[i]; i++)
|
for (i = 2; *args[i]; i++)
|
||||||
d += sprintf(d, " %s", args[i]);
|
d += snprintf(d, global.desc + len - d, " %s", args[i]);
|
||||||
}
|
}
|
||||||
else if (!strcmp(args[0], "node")) {
|
else if (!strcmp(args[0], "node")) {
|
||||||
int i;
|
int i;
|
||||||
@ -2261,9 +2261,9 @@ int cfg_parse_listen(const char *file, int linenum, char **args, int kwm)
|
|||||||
d = (char *)calloc(1, len);
|
d = (char *)calloc(1, len);
|
||||||
curproxy->desc = d;
|
curproxy->desc = d;
|
||||||
|
|
||||||
d += sprintf(d, "%s", args[1]);
|
d += snprintf(d, curproxy->desc + len - d, "%s", args[1]);
|
||||||
for (i = 2; *args[i]; i++)
|
for (i = 2; *args[i]; i++)
|
||||||
d += sprintf(d, " %s", args[i]);
|
d += snprintf(d, curproxy->desc + len - d, " %s", args[i]);
|
||||||
|
|
||||||
}
|
}
|
||||||
else if (!strcmp(args[0], "disabled")) { /* disables this proxy */
|
else if (!strcmp(args[0], "disabled")) { /* disables this proxy */
|
||||||
@ -3427,9 +3427,9 @@ int cfg_parse_listen(const char *file, int linenum, char **args, int kwm)
|
|||||||
|
|
||||||
desc = d = (char *)calloc(1, len);
|
desc = d = (char *)calloc(1, len);
|
||||||
|
|
||||||
d += sprintf(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++)
|
||||||
d += sprintf(d, " %s", args[i]);
|
d += snprintf(d, desc + len - d, " %s", args[i]);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!*args[2] && !global.desc)
|
if (!*args[2] && !global.desc)
|
||||||
@ -5138,11 +5138,13 @@ stats_error_parsing:
|
|||||||
|
|
||||||
errnum = atol(args[1]);
|
errnum = atol(args[1]);
|
||||||
if (!strcmp(args[0], "errorloc303")) {
|
if (!strcmp(args[0], "errorloc303")) {
|
||||||
err = malloc(strlen(HTTP_303) + strlen(args[2]) + 5);
|
errlen = strlen(HTTP_303) + strlen(args[2]) + 5;
|
||||||
errlen = sprintf(err, "%s%s\r\n\r\n", HTTP_303, args[2]);
|
err = malloc(errlen);
|
||||||
|
errlen = snprintf(err, errlen, "%s%s\r\n\r\n", HTTP_303, args[2]);
|
||||||
} else {
|
} else {
|
||||||
err = malloc(strlen(HTTP_302) + strlen(args[2]) + 5);
|
errlen = strlen(HTTP_302) + strlen(args[2]) + 5;
|
||||||
errlen = sprintf(err, "%s%s\r\n\r\n", HTTP_302, args[2]);
|
err = malloc(errlen);
|
||||||
|
errlen = snprintf(err, errlen, "%s%s\r\n\r\n", HTTP_302, args[2]);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (rc = 0; rc < HTTP_ERR_SIZE; rc++) {
|
for (rc = 0; rc < HTTP_ERR_SIZE; rc++) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user