From bdbd102c9c0f3fb2c0af9f2eeef2abe78390b551 Mon Sep 17 00:00:00 2001 From: "Todd C. Miller" Date: Tue, 6 Mar 2018 12:00:37 -0700 Subject: [PATCH] Fix crash when converting sudoers entry with a runas list that is present but empty. --- plugins/sudoers/cvtsudoers_json.c | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) 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: -- 2.40.0