Skip to content

Commit

Permalink
json: do not escape strings when printing the configuration
Browse files Browse the repository at this point in the history
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]>
  • Loading branch information
igaw committed Oct 28, 2024
1 parent f8f82ab commit 6f13888
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions src/nvme/json.c
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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());
Expand Down

0 comments on commit 6f13888

Please sign in to comment.