From 6f13888ab994cd42e83818f018913d78a5a7000b Mon Sep 17 00:00:00 2001 From: Daniel Wagner Date: Mon, 28 Oct 2024 17:19:58 +0100 Subject: [PATCH] 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 --- src/nvme/json.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/nvme/json.c b/src/nvme/json.c index 2f256f43..af28bd48 100644 --- a/src/nvme/json.c +++ b/src/nvme/json.c @@ -434,11 +434,14 @@ int json_update_config(nvme_root_t r, const char *config_file) } } if (!config_file) { - ret = json_object_to_fd(1, json_root, JSON_C_TO_STRING_PRETTY); + ret = json_object_to_fd(1, json_root, + JSON_C_TO_STRING_PRETTY | + JSON_C_TO_STRING_NOSLASHESCAPE); printf("\n"); } else ret = json_object_to_file_ext(config_file, json_root, - JSON_C_TO_STRING_PRETTY); + JSON_C_TO_STRING_PRETTY | + JSON_C_TO_STRING_NOSLASHESCAPE); if (ret < 0) { nvme_msg(r, LOG_ERR, "Failed to write to %s, %s\n", config_file ? "stdout" : config_file, @@ -592,7 +595,9 @@ int json_dump_tree(nvme_root_t r) } json_object_object_add(json_root, "hosts", host_array); - ret = json_object_to_fd(r->log.fd, json_root, JSON_C_TO_STRING_PRETTY); + ret = json_object_to_fd(r->log.fd, json_root, + JSON_C_TO_STRING_PRETTY | + JSON_C_TO_STRING_NOSLASHESCAPE); if (ret < 0) { nvme_msg(r, LOG_ERR, "Failed to write, %s\n", json_util_get_last_err());