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.
+ data->q += data->n;
+ data->n = 0;
+ }
+ else
+ {
+ data->q += written;
+ data->n -= written;
- data->q += written;
- data->n += written;