From: Jason A. Donenfeld Date: Sun, 15 Oct 2017 19:29:01 +0000 (+0200) Subject: wg: encoding: be more paranoid X-Git-Tag: v1.0.20191226~204 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=7fe7f81088d9ff3fb392c12ca970e79cc78e1061;p=thirdparty%2Fwireguard-tools.git wg: encoding: be more paranoid Needless, but overkill can be fun. Signed-off-by: Jason A. Donenfeld --- diff --git a/src/encoding.c b/src/encoding.c index 3d5e94b..c407b57 100644 --- a/src/encoding.c +++ b/src/encoding.c @@ -102,10 +102,10 @@ bool key_from_hex(uint8_t key[static WG_KEY_LEN], const char *hex) bool key_is_zero(const uint8_t key[static WG_KEY_LEN]) { - uint8_t acc = 0; + volatile uint8_t acc = 0; for (unsigned int i = 0; i < WG_KEY_LEN; ++i) { acc |= key[i]; __asm__ ("" : "=r" (acc) : "0" (acc)); } - return acc == 0; + return 1 & ((acc - 1) >> 8); }