Fix crash on startup on sparc64, patch from upstream.

This commit is contained in:
pascal 2015-03-23 16:21:10 +00:00
parent 8e8917a195
commit 3b596aa208
2 changed files with 55 additions and 1 deletions

View File

@ -1,8 +1,9 @@
# $OpenBSD: Makefile,v 1.76 2015/03/19 23:05:34 pascal Exp $
# $OpenBSD: Makefile,v 1.77 2015/03/23 16:21:10 pascal Exp $
COMMENT= anonymity service using onion routing
DISTNAME= tor-0.2.5.11
REVISION= 0
CATEGORIES= net
HOMEPAGE= https://www.torproject.org/

View File

@ -0,0 +1,53 @@
$OpenBSD: patch-src_ext_csiphash_c,v 1.1 2015/03/23 16:21:10 pascal Exp $
commit 732f522a42702494c4029da568a2603bb963e402
Author: Yawning Angel <yawning@schwanenlied.me>
Date: Sun Mar 22 22:31:08 2015 +0000
Fix unaligned access in SipHash-2-4.
The compiler is allowed to assume that a "uint64_t *" is aligned
correctly, and will inline a version of memcpy that acts as such.
Use "uint8_t *", so the compiler does the right thing.
--- src/ext/csiphash.c.orig Thu Mar 12 17:49:50 2015
+++ src/ext/csiphash.c Mon Mar 23 17:15:02 2015
@@ -100,10 +100,18 @@ uint64_t siphash24(const void *src, unsigned long src_
uint64_t k0 = key->k0;
uint64_t k1 = key->k1;
uint64_t b = (uint64_t)src_sz << 56;
+#ifdef UNALIGNED_OK
const uint64_t *in = (uint64_t*)src;
+#else
+ /* On platforms where alignment matters, if 'in' is a pointer to a
+ * datatype that must be aligned, the compiler is allowed to
+ * generate code that assumes that it is aligned as such.
+ */
+ const uint8_t *in = (uint8_t *)src;
+#endif
- uint64_t t;
- uint8_t *pt, *m;
+ uint64_t t;
+ uint8_t *pt, *m;
uint64_t v0 = k0 ^ 0x736f6d6570736575ULL;
uint64_t v1 = k1 ^ 0x646f72616e646f6dULL;
@@ -113,12 +121,14 @@ uint64_t siphash24(const void *src, unsigned long src_
while (src_sz >= 8) {
#ifdef UNALIGNED_OK
uint64_t mi = _le64toh(*in);
+ in += 1;
#else
uint64_t mi;
memcpy(&mi, in, 8);
mi = _le64toh(mi);
+ in += 8;
#endif
- in += 1; src_sz -= 8;
+ src_sz -= 8;
v3 ^= mi;
DOUBLE_ROUND(v0,v1,v2,v3);
v0 ^= mi;