]> granicus.if.org Git - curl/commit
infof: clearly indicate truncation
authorDaniel Gustafsson <daniel@yesql.se>
Sat, 3 Nov 2018 19:54:18 +0000 (20:54 +0100)
committerDaniel Gustafsson <daniel@yesql.se>
Sat, 3 Nov 2018 19:54:18 +0000 (20:54 +0100)
commitc37b66aaaed0a36bcb1b19596e897d7ac6219611
treeba305dc3d11d1e3b07ca699d19c88f1a95e0c2ab
parentd82a17ad850914fee6dd17aadf9c5f902cda599f
infof: clearly indicate truncation

The internal buffer in infof() is limited to 2048 bytes of payload plus
an additional byte for NULL termination. Servers with very long error
messages can however cause truncation of the string, which currently
isn't very clear, and leads to badly formatted output.

This appends a "...\n" (or just "..." in case the format didn't with a
newline char) marker to the end of the string to clearly show
that it has been truncated.

Also include a unittest covering infof() to try and catch any bugs
introduced in this quite important function.

Closes #3216
Reviewed-by: Daniel Stenberg <daniel@haxx.se>
Reviewed-by: Marcel Raad <Marcel.Raad@teamviewer.com>
lib/sendf.c
tests/data/Makefile.inc
tests/data/test1652 [new file with mode: 0644]
tests/unit/Makefile.inc
tests/unit/unit1652.c [new file with mode: 0644]