Fix sprintf usage in format json functions #293
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
hostnamectl
Operating System: Ubuntu 23.10
Kernel: Linux 6.5.0-17-generic
Architecture: x86-64
lib version
After i build odas and start, i see that *.json files only contain "}" strings(2251 in my case) like this
How i build ODAS
What exactly is the problem and why should you not do that ?
sprintf(buff, “%s %s”, buff, “some text”); - incorrect usage
https://stackoverflow.com/questions/1973572/can-the-input-and-output-strings-to-sprintf-be-the-same
https://stackoverflow.com/questions/21912061/strange-output-of-sprintf-whats-causing-it
opengroup
https://pvs-studio.com/en/docs/warnings/v541/
Files and functions affected
odas/src/sink/snk_pots.c:snk_pots_process_format_text_json
odas/src/sink/snk_tracks.c:snk_tracks_process_format_text_json
odas/src/sink/snk_categories.c:snk_categories_process_format_text_json
After commit
Tested with config on three json variants - everything works fine: