From da174a1fe94b718d1403f4a4fb8130a2131f0465 Mon Sep 17 00:00:00 2001 From: christos Date: Wed, 2 Oct 2019 15:43:15 +0000 Subject: [PATCH] PR/54594: Martin Husemann: bind may crash at startup Use memcpy(3) instead of assuming casting "uint8_t *" to "uint64_t *" and de-referencing works. --- external/mpl/bind/dist/lib/isc/siphash.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/external/mpl/bind/dist/lib/isc/siphash.c b/external/mpl/bind/dist/lib/isc/siphash.c index a7f1ac7275ab..76da19e9bea6 100644 --- a/external/mpl/bind/dist/lib/isc/siphash.c +++ b/external/mpl/bind/dist/lib/isc/siphash.c @@ -1,4 +1,4 @@ -/* $NetBSD: siphash.c,v 1.2 2019/09/05 19:32:59 christos Exp $ */ +/* $NetBSD: siphash.c,v 1.3 2019/10/02 15:43:15 christos Exp $ */ /* * Copyright (C) Internet Systems Consortium, Inc. ("ISC") @@ -60,9 +60,13 @@ void isc_siphash24(const uint8_t *k, const uint8_t *in, size_t inlen, uint8_t *out) { - const uint64_t *key = (const uint64_t *)k; - uint64_t k0 = le64toh(key[0]); - uint64_t k1 = le64toh(key[1]); + uint64_t k0, k1; + + memcpy(&k0, k, sizeof(k0)); + memcpy(&k1, k + sizeof(k0), sizeof(k1)); + + k0 = le64toh(k0); + k1 = le64toh(k1); uint64_t v0 = 0x736f6d6570736575ULL ^ k0; uint64_t v1 = 0x646f72616e646f6dULL ^ k1;