Don't cast second argument of mem_printf_hook (%b) to size_t.
Also treat the given number as unsigned int. Due to the printf hook registration the second argument of mem_printf_hook (if called via printf etc.) is always of type int*. Casting this to a size_t pointer and then dereferencing that as int does not work on big endian machines if int is smaller than size_t (e.g. on ppc64). In order to make this change work if the argument is of a type larger than int, size_t for instance, the second argument for %b has to be casted to (u_)int.
This commit is contained in:
@@ -444,7 +444,7 @@ int mem_printf_hook(char *dst, size_t dstlen,
|
||||
printf_hook_spec_t *spec, const void *const *args)
|
||||
{
|
||||
char *bytes = *((void**)(args[0]));
|
||||
int len = *((size_t*)(args[1]));
|
||||
u_int len = *((int*)(args[1]));
|
||||
|
||||
char buffer[BYTES_PER_LINE * 3];
|
||||
char ascii_buffer[BYTES_PER_LINE + 1];
|
||||
@@ -455,7 +455,7 @@ int mem_printf_hook(char *dst, size_t dstlen,
|
||||
int i = 0;
|
||||
int written = 0;
|
||||
|
||||
written += print_in_hook(dst, dstlen, "=> %d bytes @ %p", len, bytes);
|
||||
written += print_in_hook(dst, dstlen, "=> %u bytes @ %p", len, bytes);
|
||||
|
||||
while (bytes_pos < bytes_roof)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user