2
0
mirror of https://github.com/sudo-project/sudo.git synced 2025-09-04 00:05:11 +00:00

It is possible for evlog->argv or evlog->envp to be NULL.

This commit is contained in:
Todd C. Miller
2020-11-17 13:43:31 -07:00
parent 24d812d037
commit cb87253d1e

View File

@@ -786,19 +786,23 @@ fmt_info_messages(struct client_closure *closure, size_t *n_info_msgs)
debug_decl(fmt_info_messages, SUDOERS_DEBUG_UTIL); debug_decl(fmt_info_messages, SUDOERS_DEBUG_UTIL);
/* Convert NULL-terminated vectors to StringList. */ /* Convert NULL-terminated vectors to StringList. */
if (evlog->argv != NULL) {
if ((runargv = malloc(sizeof(*runargv))) == NULL) if ((runargv = malloc(sizeof(*runargv))) == NULL)
goto bad; goto bad;
info_message__string_list__init(runargv); info_message__string_list__init(runargv);
runargv->strings = evlog->argv; runargv->strings = evlog->argv;
while (runargv->strings[runargv->n_strings] != NULL) while (runargv->strings[runargv->n_strings] != NULL)
runargv->n_strings++; runargv->n_strings++;
}
if (evlog->envp != NULL) {
if ((runenv = malloc(sizeof(*runenv))) == NULL) if ((runenv = malloc(sizeof(*runenv))) == NULL)
goto bad; goto bad;
info_message__string_list__init(runenv); info_message__string_list__init(runenv);
runenv->strings = evlog->envp; runenv->strings = evlog->envp;
while (runenv->strings[runenv->n_strings] != NULL) while (runenv->strings[runenv->n_strings] != NULL)
runenv->n_strings++; runenv->n_strings++;
}
/* XXX - realloc as needed instead of preallocating */ /* XXX - realloc as needed instead of preallocating */
info_msgs_size = 24; info_msgs_size = 24;
@@ -835,17 +839,21 @@ fmt_info_messages(struct client_closure *closure, size_t *n_info_msgs)
info_msgs[n]->value_case = INFO_MESSAGE__VALUE_NUMVAL; info_msgs[n]->value_case = INFO_MESSAGE__VALUE_NUMVAL;
n++; n++;
if (runargv != NULL) {
info_msgs[n]->key = "runargv"; info_msgs[n]->key = "runargv";
info_msgs[n]->u.strlistval = runargv; info_msgs[n]->u.strlistval = runargv;
info_msgs[n]->value_case = INFO_MESSAGE__VALUE_STRLISTVAL; info_msgs[n]->value_case = INFO_MESSAGE__VALUE_STRLISTVAL;
n++; n++;
}
if (runenv != NULL) {
info_msgs[n]->key = "runenv"; info_msgs[n]->key = "runenv";
info_msgs[n]->u.strlistval = runenv; info_msgs[n]->u.strlistval = runenv;
info_msgs[n]->value_case = INFO_MESSAGE__VALUE_STRLISTVAL; info_msgs[n]->value_case = INFO_MESSAGE__VALUE_STRLISTVAL;
n++; n++;
}
if (evlog->rungroup!= NULL) { if (evlog->rungroup != NULL) {
info_msgs[n]->key = "rungid"; info_msgs[n]->key = "rungid";
info_msgs[n]->u.numval = evlog->rungid; info_msgs[n]->u.numval = evlog->rungid;
info_msgs[n]->value_case = INFO_MESSAGE__VALUE_NUMVAL; info_msgs[n]->value_case = INFO_MESSAGE__VALUE_NUMVAL;