Skip to content

Commit

Permalink
Merge pull request #1130
Browse files Browse the repository at this point in the history
json generation: Fix some leaks and an integer overflow
  • Loading branch information
arogge committed Jan 26, 2023
2 parents eb2d714 + 2310ab1 commit 7e85698
Show file tree
Hide file tree
Showing 7 changed files with 145 additions and 187 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Expand Up @@ -11,6 +11,7 @@ and since Bareos version 20 this project adheres to [Semantic Versioning](https:
- build: replace sprintf by snprintf due to upgraded MacOS compiler, change linking of googletest [PR #1361]
- storage daemon: fix crash on volume swap [PR #1356]
- core: make resource/configuration locking safer [PR #1325]
- json generation: Fix some leaks and an integer overflow [PR #1130]

### Removed
- remove no longer used pkglists [PR #1335]
Expand All @@ -26,6 +27,7 @@ and since Bareos version 20 this project adheres to [Semantic Versioning](https:
- add explanation about binary version numbers [PR #1354]

[PR #935]: https://github.com/bareos/bareos/pull/935
[PR #1130]: https://github.com/bareos/bareos/pull/1130
[PR #1325]: https://github.com/bareos/bareos/pull/1325
[PR #1335]: https://github.com/bareos/bareos/pull/1335
[PR #1343]: https://github.com/bareos/bareos/pull/1343
Expand Down
11 changes: 7 additions & 4 deletions core/src/console/console_conf.cc
Expand Up @@ -274,16 +274,19 @@ bool PrintConfigSchemaJson(PoolMem& buffer)
json_object_set_new(json, "version", json_string(kBareosVersionStrings.Full));

json_t* json_resource_object = json_object();
json_object_set(json, "resource", json_resource_object);
json_object_set_new(json, "resource", json_resource_object);
json_t* bconsole = json_object();
json_object_set(json_resource_object, "bconsole", bconsole);
json_object_set_new(json_resource_object, "bconsole", bconsole);

ResourceTable* resources = my_config->resource_definitions_;
for (; resources->name; ++resources) {
json_object_set(bconsole, resources->name, json_items(resources->items));
json_object_set_new(bconsole, resources->name,
json_items(resources->items));
}

PmStrcat(buffer, json_dumps(json, JSON_INDENT(2)));
char* const json_str = json_dumps(json, JSON_INDENT(2));
PmStrcat(buffer, json_str);
free(json_str);
json_decref(json);

return true;
Expand Down

0 comments on commit 7e85698

Please sign in to comment.