summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorderaadt <deraadt@openbsd.org>2017-04-12 17:41:49 +0000
committerderaadt <deraadt@openbsd.org>2017-04-12 17:41:49 +0000
commit19f78c5e992334b272aab66e813e74eaa46da711 (patch)
tree590097a2c639c8c0d3c3b942d58f792ac2462c65
parentNew strstr() implementation from musl libc by Rich Felker. This (diff)
downloadwireguard-openbsd-19f78c5e992334b272aab66e813e74eaa46da711.tar.xz
wireguard-openbsd-19f78c5e992334b272aab66e813e74eaa46da711.zip
SipHash_Final() was assuming the digest was 64-bit aligned, resulting in
misaligned memory accesses with armv7 ramdisk -Os bsd.rd ping ok florian millert
-rw-r--r--lib/libc/hash/siphash.c7
1 files changed, 3 insertions, 4 deletions
diff --git a/lib/libc/hash/siphash.c b/lib/libc/hash/siphash.c
index 0f056a35811..845c8b6f5a9 100644
--- a/lib/libc/hash/siphash.c
+++ b/lib/libc/hash/siphash.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: siphash.c,v 1.5 2015/09/11 09:18:27 guenther Exp $ */
+/* $OpenBSD: siphash.c,v 1.6 2017/04/12 17:41:49 deraadt Exp $ */
/*-
* Copyright (c) 2013 Andre Oppermann <andre@FreeBSD.org>
@@ -113,9 +113,8 @@ SipHash_Final(void *dst, SIPHASH_CTX *ctx, int rc, int rf)
{
uint64_t r;
- r = SipHash_End(ctx, rc, rf);
-
- *(uint64_t *)dst = htole64(r);
+ r = htole64(SipHash_End(ctx, rc, rf));
+ memcpy(dst, &r, sizeof r);
}
DEF_WEAK(SipHash_Final);