From: Todd C. Miller Date: Tue, 6 Mar 2018 19:00:37 +0000 (-0700) Subject: Fix crash when converting sudoers entry with a runas list that is X-Git-Tag: SUDO_1_8_23^2~86 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=bdbd102c9c0f3fb2c0af9f2eeef2abe78390b551;p=sudo Fix crash when converting sudoers entry with a runas list that is present but empty. --- diff --git a/plugins/sudoers/cvtsudoers_json.c b/plugins/sudoers/cvtsudoers_json.c index 825bb3826..dbee32657 100644 --- a/plugins/sudoers/cvtsudoers_json.c +++ b/plugins/sudoers/cvtsudoers_json.c @@ -344,7 +344,20 @@ print_member_json_int(FILE *fp, char *name, int type, bool negated, /* Most of the time we print a string. */ value.type = JSON_STRING; - value.u.string = name; + if (name != NULL) { + value.u.string = name; + } else { + switch (type) { + case ALL: + value.u.string = "ALL"; + break; + case MYSELF: + value.u.string = ""; + break; + default: + sudo_fatalx("missing member name for type %d", type); + } + } switch (type) { case USERGROUP: @@ -389,8 +402,7 @@ print_member_json_int(FILE *fp, char *name, int type, bool negated, print_command_json(fp, name, type, negated, indent, last_one); debug_return; case ALL: - value.u.string = "ALL"; - /* FALLTHROUGH */ + case MYSELF: case WORD: switch (word_type) { case TYPE_COMMAND: