Skip to content

Commit 6f13888

Browse files
dwsuseigaw
authored andcommitted
json: do not escape strings when printing the configuration
TLS keys are using a base64 encoding thus the additional slash encoding will corrupt the key. nvme-cli already uses this option for the rest, so it should be fine here too. Signed-off-by: Daniel Wagner <[email protected]>
1 parent f8f82ab commit 6f13888

1 file changed

Lines changed: 8 additions & 3 deletions

File tree

src/nvme/json.c

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -434,11 +434,14 @@ int json_update_config(nvme_root_t r, const char *config_file)
434434
}
435435
}
436436
if (!config_file) {
437-
ret = json_object_to_fd(1, json_root, JSON_C_TO_STRING_PRETTY);
437+
ret = json_object_to_fd(1, json_root,
438+
JSON_C_TO_STRING_PRETTY |
439+
JSON_C_TO_STRING_NOSLASHESCAPE);
438440
printf("\n");
439441
} else
440442
ret = json_object_to_file_ext(config_file, json_root,
441-
JSON_C_TO_STRING_PRETTY);
443+
JSON_C_TO_STRING_PRETTY |
444+
JSON_C_TO_STRING_NOSLASHESCAPE);
442445
if (ret < 0) {
443446
nvme_msg(r, LOG_ERR, "Failed to write to %s, %s\n",
444447
config_file ? "stdout" : config_file,
@@ -592,7 +595,9 @@ int json_dump_tree(nvme_root_t r)
592595
}
593596
json_object_object_add(json_root, "hosts", host_array);
594597

595-
ret = json_object_to_fd(r->log.fd, json_root, JSON_C_TO_STRING_PRETTY);
598+
ret = json_object_to_fd(r->log.fd, json_root,
599+
JSON_C_TO_STRING_PRETTY |
600+
JSON_C_TO_STRING_NOSLASHESCAPE);
596601
if (ret < 0) {
597602
nvme_msg(r, LOG_ERR, "Failed to write, %s\n",
598603
json_util_get_last_err());

0 commit comments

Comments
 (0)