[29608] in CVS-changelog-for-Kerberos-V5

home help back first fref pref prev next nref lref last post

krb5 commit [krb5-1.14]: Avoid unaligned access in btree byte swapping

daemon@ATHENA.MIT.EDU (Tom Yu)
Fri Sep 2 17:04:40 2016

Date: Fri, 2 Sep 2016 17:04:37 -0400
From: Tom Yu <tlyu@mit.edu>
Message-Id: <201609022104.u82L4b2b024068@drugstore.mit.edu>
To: cvs-krb5@mit.edu
Reply-To: krbdev@mit.edu
MIME-Version: 1.0
Content-Type: text/plain; charset="us-ascii"
Content-Transfer-Encoding: 7bit
Errors-To: cvs-krb5-bounces@mit.edu

https://github.com/krb5/krb5/commit/2e1d229805ef1358ae8e975d7972ec717ed5c5e2
commit 2e1d229805ef1358ae8e975d7972ec717ed5c5e2
Author: Tom Yu <tlyu@mit.edu>
Date:   Fri Aug 26 13:56:18 2016 -0400

    Avoid unaligned access in btree byte swapping
    
    Apply a patch from NetBSD to use temporary character buffers instead
    of doing an unaligned read when swapping bytes.
    
    (cherry picked from commit 0936b2578b64be2c53c8cfccd70cbe93519d42fa)
    
    ticket: 8484
    version_fixed: 1.14.4

 src/plugins/kdb/db2/libdb2/include/db-int.h |   22 ++++++++++++++--------
 1 files changed, 14 insertions(+), 8 deletions(-)

diff --git a/src/plugins/kdb/db2/libdb2/include/db-int.h b/src/plugins/kdb/db2/libdb2/include/db-int.h
index 0dcbf40..7e981d4 100644
--- a/src/plugins/kdb/db2/libdb2/include/db-int.h
+++ b/src/plugins/kdb/db2/libdb2/include/db-int.h
@@ -160,11 +160,15 @@ typedef u_int32_t	recno_t;
 	((char *)&a)[3] = ((char *)&_tmp)[0];				\
 }
 #define	P_32_SWAP(a) {							\
-	u_int32_t _tmp = *(u_int32_t *)a;				\
-	((char *)a)[0] = ((char *)&_tmp)[3];				\
-	((char *)a)[1] = ((char *)&_tmp)[2];				\
-	((char *)a)[2] = ((char *)&_tmp)[1];				\
-	((char *)a)[3] = ((char *)&_tmp)[0];				\
+	char _tmp[4];							\
+	_tmp[0] = ((char *)a)[0];					\
+	_tmp[1] = ((char *)a)[1];					\
+	_tmp[2] = ((char *)a)[2];					\
+	_tmp[3] = ((char *)a)[3];					\
+	((char *)a)[0] = _tmp[3];					\
+	((char *)a)[1] = _tmp[2];					\
+	((char *)a)[2] = _tmp[1];					\
+	((char *)a)[3] = _tmp[0];					\
 }
 #define	P_32_COPY(a, b) {						\
 	((char *)&(b))[0] = ((char *)&(a))[3];				\
@@ -185,9 +189,11 @@ typedef u_int32_t	recno_t;
 	((char *)&a)[1] = ((char *)&_tmp)[0];				\
 }
 #define	P_16_SWAP(a) {							\
-	u_int16_t _tmp = *(u_int16_t *)a;				\
-	((char *)a)[0] = ((char *)&_tmp)[1];				\
-	((char *)a)[1] = ((char *)&_tmp)[0];				\
+	char _tmp[2];							\
+	_tmp[0] = ((char *)a)[0];					\
+	_tmp[1] = ((char *)a)[1];					\
+	((char *)a)[0] = _tmp[1];					\
+	((char *)a)[1] = _tmp[0];					\
 }
 #define	P_16_COPY(a, b) {						\
 	((char *)&(b))[0] = ((char *)&(a))[1];				\
_______________________________________________
cvs-krb5 mailing list
cvs-krb5@mit.edu
https://mailman.mit.edu/mailman/listinfo/cvs-krb5

home help back first fref pref prev next nref lref last post