diff options
Diffstat (limited to 'src/debug.c')
-rw-r--r-- | src/debug.c | 16 |
1 files changed, 13 insertions, 3 deletions
diff --git a/src/debug.c b/src/debug.c index c071df0a9..735fce391 100644 --- a/src/debug.c +++ b/src/debug.c @@ -127,12 +127,22 @@ void debugp(unsigned int subsys, char *file, int line, int cont, const char *for fflush(outfd); } -void hexdump(unsigned char *buf, int len) +static char hexd_buff[4096]; + +char *hexdump(unsigned char *buf, int len) { int i; + char *cur = hexd_buff; + + hexd_buff[0] = 0; for (i = 0; i < len; i++) { - fprintf(stdout, "%02x ", buf[i]); + int len_remain = sizeof(hexd_buff) - (cur - hexd_buff); + int rc = snprintf(cur, len_remain, "%02x ", buf[i]); + if (rc <= 0) + break; + cur += rc; } - fprintf(stdout, "\n"); + hexd_buff[sizeof(hexd_buff)-1] = 0; + return hexd_buff; } |