tFix issues with U32() macro - libeech - bittorrent library
(HTM) git clone git://z3bra.org/libeech.git
(DIR) Log
(DIR) Files
(DIR) Refs
(DIR) README
(DIR) LICENSE
---
(DIR) commit af81ef0e03792a5408783394c1d9bc29dcc0ff0b
(DIR) parent d1b10606edf81df3f81e863bca63384d9bc44ae3
(HTM) Author: z3bra <contactatz3bradotorg>
Date: Mon, 2 Jul 2018 08:53:06 +0200
Fix issues with U32() macro
The macro was OR'ing values that were not zeroed, thus resulting in bad
values if integers were included crap random bits.
Diffstat:
M libeech.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
---
(DIR) diff --git a/libeech.c b/libeech.c
t@@ -19,7 +19,7 @@
#include "libeech.h"
/* return a 4 byte array as a 32 bit integer */
-#define U32(s) ((uint32_t)((s)[0])<<24|((s)[1])<<16|((s)[2])<<8|((s)[3]))
+#define U32(s) ((uint32_t)(((s)[0]&0xff)<<24|((s)[1]&0xff)<<16|((s)[2]&0xff)<<8|((s)[3]&0xff)))
/* Associate message types with their numerical value */
enum {