aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/src
diff options
context:
space:
mode:
authorJason A. Donenfeld <Jason@zx2c4.com>2017-10-15 21:29:01 +0200
committerJason A. Donenfeld <Jason@zx2c4.com>2017-10-17 19:26:07 +0200
commit7fe7f81088d9ff3fb392c12ca970e79cc78e1061 (patch)
tree8dd9154a4485f83553721a5eee8cf9fc3a4a1a3e /src
parentMakefile: even prettier output (diff)
downloadwireguard-tools-7fe7f81088d9ff3fb392c12ca970e79cc78e1061.tar.xz
wireguard-tools-7fe7f81088d9ff3fb392c12ca970e79cc78e1061.zip
wg: encoding: be more paranoid
Needless, but overkill can be fun. Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
Diffstat (limited to 'src')
-rw-r--r--src/encoding.c4
1 files changed, 2 insertions, 2 deletions
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);
}