Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/common/lib/libc/hash/murmurhash Fix byte order bug in murmur...



details:   https://anonhg.NetBSD.org/src/rev/77b17799e6f6
branches:  trunk
changeset: 463383:77b17799e6f6
user:      riastradh <riastradh%NetBSD.org@localhost>
date:      Tue Aug 20 12:33:26 2019 +0000

description:
Fix byte order bug in murmurhash and pacify sanitizers.

diffstat:

 common/lib/libc/hash/murmurhash/murmurhash.c |  11 +++++++----
 1 files changed, 7 insertions(+), 4 deletions(-)

diffs (36 lines):

diff -r 6a4b12131f8d -r 77b17799e6f6 common/lib/libc/hash/murmurhash/murmurhash.c
--- a/common/lib/libc/hash/murmurhash/murmurhash.c      Tue Aug 20 12:33:04 2019 +0000
+++ b/common/lib/libc/hash/murmurhash/murmurhash.c      Tue Aug 20 12:33:26 2019 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: murmurhash.c,v 1.6 2013/10/26 21:06:38 rmind Exp $     */
+/*     $NetBSD: murmurhash.c,v 1.7 2019/08/20 12:33:26 riastradh Exp $ */
 
 /*
  * MurmurHash2 -- from the original code:
@@ -14,12 +14,12 @@
 #include <sys/cdefs.h>
 
 #if defined(_KERNEL) || defined(_STANDALONE)
-__KERNEL_RCSID(0, "$NetBSD: murmurhash.c,v 1.6 2013/10/26 21:06:38 rmind Exp $");
+__KERNEL_RCSID(0, "$NetBSD: murmurhash.c,v 1.7 2019/08/20 12:33:26 riastradh Exp $");
 
 #else
 
 #if defined(LIBC_SCCS) && !defined(lint)
-__RCSID("$NetBSD: murmurhash.c,v 1.6 2013/10/26 21:06:38 rmind Exp $");
+__RCSID("$NetBSD: murmurhash.c,v 1.7 2019/08/20 12:33:26 riastradh Exp $");
 #endif /* LIBC_SCCS and not lint */
 
 #include "namespace.h"
@@ -51,7 +51,10 @@
 
        if (__predict_true(ALIGNED_POINTER(key, uint32_t))) {
                while (len >= sizeof(uint32_t)) {
-                       uint32_t k = *(const uint32_t *)data;
+                       uint32_t k;
+
+                       ALIGNED_POINTER_LOAD(&k, data, uint32_t);
+                       k = htole32(k);
 
                        k *= m;
                        k ^= k >> r;



Home | Main Index | Thread Index | Old Index