]> prime8.dev >> repos - ttyd.git/commitdiff
Fix potential segmentation fault (SIGSEGV) error #209 (#210)
authorAdela0602 <53685844+Adela0602@users.noreply.github.com>
Sun, 4 Aug 2019 13:11:30 +0000 (21:11 +0800)
committerShuanglei Tao <tsl0922@gmail.com>
Sun, 4 Aug 2019 13:11:30 +0000 (21:11 +0800)
src/server.c

index 87454afa0fe643ca38b015f32c9d5a66468b6e78..cea5774364a1add0a9653eb61f68028f71fc41a0 100644 (file)
@@ -382,6 +382,10 @@ main(int argc, char **argv) {
                         return -1;
                     }
                     char *value = strsep(&option, "=");
+                    if (value == NULL) {
+                        fprintf(stderr, "ttyd: invalid client option: %s, format: key=value\n", optarg);
+                        return -1;
+                    }
                     free(option);
                     struct json_object *obj = json_tokener_parse(value);
                     json_object_object_add(client_prefs, key, obj != NULL ? obj : json_object_new_string(value));