Avoid some PVS-Studio false positives.

This commit is contained in:
Todd C. Miller
2018-10-19 13:35:20 -06:00
parent e9dec0f8d2
commit 8c94175ba1
5 changed files with 10 additions and 7 deletions

View File

@@ -71,12 +71,12 @@ linux_audit_command(char *argv[], int result)
/* Convert argv to a flat string. */
for (size = 0, av = argv; *av != NULL; av++)
size += strlen(*av) + 1;
command = cp = malloc(size);
command = malloc(size);
if (command == NULL) {
sudo_warnx(U_("%s: %s"), __func__, U_("unable to allocate memory"));
goto done;
}
for (av = argv; *av != NULL; av++) {
for (av = argv, cp = command; *av != NULL; av++) {
n = strlcpy(cp, *av, size - (cp - command));
if (n >= size - (cp - command)) {
sudo_warnx(U_("internal error, %s overflow"), __func__);