From e31e0c4d3f1f1c668967dc407fe4960a218c1d8c Mon Sep 17 00:00:00 2001 From: "Todd C. Miller" Date: Mon, 6 Apr 2020 07:18:58 -0600 Subject: [PATCH] Don't pass a NULL submitcwd or ttyname value to the server. It is possible for the cwd and/or tty to be missing. If we send a NULL pointer to the server where it expects a string the AcceptMessage will fail to parse. --- plugins/sudoers/iolog_client.c | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/plugins/sudoers/iolog_client.c b/plugins/sudoers/iolog_client.c index 789b7c9a3..7db5b9860 100644 --- a/plugins/sudoers/iolog_client.c +++ b/plugins/sudoers/iolog_client.c @@ -746,10 +746,12 @@ fmt_accept_message(struct client_closure *closure) accept_msg.info_msgs[n]->value_case = INFO_MESSAGE__VALUE_STRVAL; n++; - accept_msg.info_msgs[n]->key = "submitcwd"; - accept_msg.info_msgs[n]->strval = (char *)details->cwd; - accept_msg.info_msgs[n]->value_case = INFO_MESSAGE__VALUE_STRVAL; - n++; + if (details->cwd != NULL) { + accept_msg.info_msgs[n]->key = "submitcwd"; + accept_msg.info_msgs[n]->strval = (char *)details->cwd; + accept_msg.info_msgs[n]->value_case = INFO_MESSAGE__VALUE_STRVAL; + n++; + } /* TODO - submitenv */ /* TODO - submitgid */ @@ -769,10 +771,12 @@ fmt_accept_message(struct client_closure *closure) accept_msg.info_msgs[n]->value_case = INFO_MESSAGE__VALUE_STRVAL; n++; - accept_msg.info_msgs[n]->key = "ttyname"; - accept_msg.info_msgs[n]->strval = (char *)details->tty; - accept_msg.info_msgs[n]->value_case = INFO_MESSAGE__VALUE_STRVAL; - n++; + if (details->tty != NULL) { + accept_msg.info_msgs[n]->key = "ttyname"; + accept_msg.info_msgs[n]->strval = (char *)details->tty; + accept_msg.info_msgs[n]->value_case = INFO_MESSAGE__VALUE_STRVAL; + n++; + } /* Update n_info_msgs. */ accept_msg.n_info_msgs = n;