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

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

krb5 commit: Avoid unaligned access in btree byte swapping

daemon@ATHENA.MIT.EDU (Tom Yu)
Tue Aug 30 15:07:44 2016

Date: Tue, 30 Aug 2016 15:07:39 -0400
From: Tom Yu <tlyu@mit.edu>
Message-Id: <201608301907.u7UJ7dWU016318@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/0936b2578b64be2c53c8cfccd70cbe93519d42fa
commit 0936b2578b64be2c53c8cfccd70cbe93519d42fa
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.
    
    ticket: 8484 (new)
    target_version: 1.14-next
    target_version: 1.13-next
    tags: pullup

 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