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:
Tobias Brunner
2012-03-27 09:10:34 +02:00
parent adfd3b992f
commit 817ab8a8d4
9 changed files with 25 additions and 19 deletions
+2 -1
View File
@@ -668,7 +668,8 @@ int chunk_printf_hook(char *dst, size_t len, printf_hook_spec_t *spec,
if (!spec->hash)
{
const void *new_args[] = {&chunk->ptr, &chunk->len};
u_int chunk_len = chunk->len;
const void *new_args[] = {&chunk->ptr, &chunk_len};
return mem_printf_hook(dst, len, spec, new_args);
}