]> granicus.if.org Git - sudo/commitdiff
Fix crash when converting sudoers entry with a runas list that is
authorTodd C. Miller <Todd.Miller@sudo.ws>
Tue, 6 Mar 2018 19:00:37 +0000 (12:00 -0700)
committerTodd C. Miller <Todd.Miller@sudo.ws>
Tue, 6 Mar 2018 19:00:37 +0000 (12:00 -0700)
present but empty.

plugins/sudoers/cvtsudoers_json.c

index 825bb3826cefe7cd3d6582eb5713ff846a42b90d..dbee32657e3dfeab3c86b93192005f9d6432c8a9 100644 (file)
@@ -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: