]> git.ipfire.org Git - thirdparty/json-c.git/commit
Properly format errnos in _json_c_strerror 663/head
authorTobias Stoeckmann <tobias@stoeckmann.org>
Sat, 22 Aug 2020 09:35:50 +0000 (11:35 +0200)
committerTobias Stoeckmann <tobias@stoeckmann.org>
Sat, 22 Aug 2020 09:35:50 +0000 (11:35 +0200)
commit4298431150df9a83390a14006217c230e684994b
tree1b3294f56fc7b49bf3eed3d41ffebe73561802ab
parent2b439ea59857747067e8272011ad67303e0d4cf1
Properly format errnos in _json_c_strerror

The function _json_c_strerror does not properly format unknown errnos.
The int to ascii loop ignores the leading digit if the number can be
divided by 10 and if an errno has been formatted, shorter errnos would
not properly terminate the newly created string, showing the ending
numbers of the previous output.

A test case has been added to show these effects.

Since this function has been introduced for tests, the effect of this on
real life code is basically non-existing. First an environment variable
has to be set to activate this strerror code and second an unknown errno
would have to be encountered.
strerror_override.c
tests/CMakeLists.txt
tests/test_strerror.c [new file with mode: 0644]
tests/test_strerror.expected [new file with mode: 0644]
tests/test_strerror.test [new symlink]