diff options
author | Damien Miller <djm@cvs.openbsd.org> | 2013-07-20 01:43:47 +0000 |
---|---|---|
committer | Damien Miller <djm@cvs.openbsd.org> | 2013-07-20 01:43:47 +0000 |
commit | f3744e41f7217ddd30287199602bc0c85e695f6c (patch) | |
tree | 888aa169181365a93b934a78442827dccfacce70 /usr.bin | |
parent | 0c604c1021902985e0b5b320842d482f5a390bb4 (diff) |
use a union to ensure correct alignment; ok deraadt
Diffstat (limited to 'usr.bin')
-rw-r--r-- | usr.bin/ssh/umac.c | 16 |
1 files changed, 9 insertions, 7 deletions
diff --git a/usr.bin/ssh/umac.c b/usr.bin/ssh/umac.c index 284c9f3b3e0..4e1ed05dac8 100644 --- a/usr.bin/ssh/umac.c +++ b/usr.bin/ssh/umac.c @@ -1,4 +1,4 @@ -/* $OpenBSD: umac.c,v 1.5 2013/05/17 00:13:14 djm Exp $ */ +/* $OpenBSD: umac.c,v 1.6 2013/07/20 01:43:46 djm Exp $ */ /* ----------------------------------------------------------------------- * * umac.c -- C Implementation UMAC Message Authentication @@ -242,19 +242,21 @@ static void pdf_gen_xor(pdf_ctx *pc, UINT8 nonce[8], UINT8 buf[8]) #elif (UMAC_OUTPUT_LEN > 8) #define LOW_BIT_MASK 0 #endif - - UINT8 tmp_nonce_lo[4]; + union { + UINT8 tmp_nonce_lo[4]; + UINT32 align; + } t; #if LOW_BIT_MASK != 0 int ndx = nonce[7] & LOW_BIT_MASK; #endif - *(UINT32 *)tmp_nonce_lo = ((UINT32 *)nonce)[1]; - tmp_nonce_lo[3] &= ~LOW_BIT_MASK; /* zero last bit */ + *(UINT32 *)t.tmp_nonce_lo = ((UINT32 *)nonce)[1]; + t.tmp_nonce_lo[3] &= ~LOW_BIT_MASK; /* zero last bit */ - if ( (((UINT32 *)tmp_nonce_lo)[0] != ((UINT32 *)pc->nonce)[1]) || + if ( (((UINT32 *)t.tmp_nonce_lo)[0] != ((UINT32 *)pc->nonce)[1]) || (((UINT32 *)nonce)[0] != ((UINT32 *)pc->nonce)[0]) ) { ((UINT32 *)pc->nonce)[0] = ((UINT32 *)nonce)[0]; - ((UINT32 *)pc->nonce)[1] = ((UINT32 *)tmp_nonce_lo)[0]; + ((UINT32 *)pc->nonce)[1] = ((UINT32 *)t.tmp_nonce_lo)[0]; aes_encryption(pc->nonce, pc->cache, pc->prf_key); } |