printf-hook-builtin: Correctly calculate written bytes in print_in_hook()
authorMartin Willi <martin@revosec.ch>
Wed, 15 Jan 2014 17:18:24 +0000 (18:18 +0100)
committerMartin Willi <martin@revosec.ch>
Wed, 15 Jan 2014 17:28:43 +0000 (18:28 +0100)
commit2e89bc4b66fcfac358443201fc0b99b64ddb432f
treec125128a1c0fcb9ea2d225b05cdfe6a5e73d1977
parenta48d19a3bfa999b0aa5451ebb258f5411c027173
printf-hook-builtin: Correctly calculate written bytes in print_in_hook()

The hook data counts remaining buffer bytes, not used ones. Counting them
correctly fixes a crash for long hexdumps.

Further, print_in_hook() must return the number of bytes that would have been
written, not the actually written bytes. This is important, as we allocate a
dynamic buffer in bus that relies on the exact byte count. Fixes long hexdumps
that got truncated.
src/libstrongswan/utils/printf_hook/printf_hook_builtin.c