Avoid some PVS-Studio false positives.
This commit is contained in:
@@ -44,7 +44,7 @@ sudo_new_key_val_v1(const char *key, const char *val)
|
||||
debug_decl(sudo_new_key_val, SUDO_DEBUG_UTIL)
|
||||
|
||||
cp = str = malloc(key_len + 1 + val_len + 1);
|
||||
if (str != NULL) {
|
||||
if (cp != NULL) {
|
||||
memcpy(cp, key, key_len);
|
||||
cp += key_len;
|
||||
*cp++ = '=';
|
||||
|
@@ -162,13 +162,14 @@ expand_iolog_path(const char *prefix, const char *dir, const char *file,
|
||||
/* Expanded path must be <= PATH_MAX */
|
||||
if (prefix != NULL)
|
||||
prelen = strlen(prefix);
|
||||
dst = path = malloc(prelen + PATH_MAX);
|
||||
path = malloc(prelen + PATH_MAX);
|
||||
if (path == NULL) {
|
||||
sudo_warnx(U_("%s: %s"), __func__, U_("unable to allocate memory"));
|
||||
goto bad;
|
||||
}
|
||||
*path = '\0';
|
||||
pathend = path + prelen + PATH_MAX;
|
||||
dst = path;
|
||||
|
||||
/* Copy prefix, if present. */
|
||||
if (prefix != NULL) {
|
||||
|
@@ -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__);
|
||||
|
@@ -104,11 +104,12 @@ fill_cmnd(const char *src, size_t len)
|
||||
arg_len = arg_size = 0;
|
||||
|
||||
dst = sudoerslval.command.cmnd = malloc(len + 1);
|
||||
if (sudoerslval.command.cmnd == NULL) {
|
||||
if (dst == NULL) {
|
||||
sudo_warnx(U_("%s: %s"), __func__, U_("unable to allocate memory"));
|
||||
sudoerserror(NULL);
|
||||
debug_return_bool(false);
|
||||
}
|
||||
sudoerslval.command.args = NULL;
|
||||
|
||||
/* Copy the string and collapse any escaped sudo-specific characters. */
|
||||
for (i = 0; i < len; i++) {
|
||||
@@ -119,7 +120,6 @@ fill_cmnd(const char *src, size_t len)
|
||||
}
|
||||
*dst = '\0';
|
||||
|
||||
sudoerslval.command.args = NULL;
|
||||
debug_return_bool(true);
|
||||
}
|
||||
|
||||
|
@@ -59,16 +59,18 @@ add_preserved_fd(struct preserved_fd_list *pfds, int fd)
|
||||
sudo_debug_printf(SUDO_DEBUG_DEBUG|SUDO_DEBUG_LINENO,
|
||||
"fd %d already preserved", fd);
|
||||
free(pfd_new);
|
||||
pfd_new = NULL;
|
||||
break;
|
||||
}
|
||||
if (fd < pfd->highfd) {
|
||||
TAILQ_INSERT_BEFORE(pfd, pfd_new, entries);
|
||||
sudo_debug_printf(SUDO_DEBUG_DEBUG|SUDO_DEBUG_LINENO,
|
||||
"preserving fd %d", fd);
|
||||
pfd_new = NULL;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (pfd == NULL) {
|
||||
if (pfd_new != NULL) {
|
||||
TAILQ_INSERT_TAIL(pfds, pfd_new, entries);
|
||||
sudo_debug_printf(SUDO_DEBUG_DEBUG|SUDO_DEBUG_LINENO,
|
||||
"preserving fd %d", fd);
|
||||
|
Reference in New Issue
Block a user