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++ = '=';
/* 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) {
/* 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__);
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++) {
}
*dst = '\0';
- sudoerslval.command.args = NULL;
debug_return_bool(true);
}
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);