# HG changeset patch # User William Astle # Date 1469896514 21600 # Node ID a11b330771e0fcdabf4b27efdb54d1d5e259a60e # Parent cf915ece9e484f8405b9f3c95e688543c1ea33fd 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. diff -r cf915ece9e48 -r a11b330771e0 src/lwwire.c --- 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; }