Mercurial > hg > index.cgi
changeset 9:a11b330771e0
Fix buffer pointer handling when logging received bytes
Actually save the read buffer pointer so we can log the actual protocol
bytes read in all cases correctly instead of displaying out of bounds memory
in the case where the packet arrives in multiple pieces.
author | William Astle <lost@l-w.ca> |
---|---|
date | Sat, 30 Jul 2016 10:35:14 -0600 |
parents | cf915ece9e48 |
children | 36c4cda4b6c4 |
files | src/lwwire.c |
diffstat | 1 files changed, 2 insertions(+), 1 deletions(-) [+] |
line wrap: on
line diff
--- a/src/lwwire.c Sat Jul 16 18:56:01 2016 -0600 +++ b/src/lwwire.c Sat Jul 30 10:35:14 2016 -0600 @@ -385,6 +385,7 @@ */ int lwwire_readdata(void *buf, int len, int itimeout) { + char *obuf = buf; int toread = len; int rv; fd_set fdset; @@ -463,7 +464,7 @@ } fprintf(stderr, "Protocol bytes read (%d):", len); for (rv = 0; rv < len; rv++) - fprintf(stderr, " %02X ", ((char *)(buf))[rv] & 0xff); + fprintf(stderr, " %02X ", (obuf[rv]) & 0xff); fprintf(stderr, "\n"); return len; }