apr-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jor...@apache.org
Subject svn commit: r1420109 - /apr/apr/trunk/random/unix/sha2.c
Date Tue, 11 Dec 2012 11:56:17 GMT
Author: jorton
Date: Tue Dec 11 11:56:10 2012
New Revision: 1420109

URL: http://svn.apache.org/viewvc?rev=1420109&view=rev
Log:
* random/unix/sha2.c (apr__SHA256_Final): Avoid C pointer aliasing
  violation.

Submitted by: Jan Kaluza <jkaluza redhat.com>

Modified:
    apr/apr/trunk/random/unix/sha2.c

Modified: apr/apr/trunk/random/unix/sha2.c
URL: http://svn.apache.org/viewvc/apr/apr/trunk/random/unix/sha2.c?rev=1420109&r1=1420108&r2=1420109&view=diff
==============================================================================
--- apr/apr/trunk/random/unix/sha2.c (original)
+++ apr/apr/trunk/random/unix/sha2.c Tue Dec 11 11:56:10 2012
@@ -465,7 +465,14 @@ void apr__SHA256_Final(sha2_byte digest[
                         *context->buffer = 0x80;
                 }
                 /* Set the bit count: */
-                *(sha2_word64*)&context->buffer[SHA256_SHORT_BLOCK_LENGTH] = context->bitcount;
+                {
+                        union dummy {
+                                apr_uint64_t bitcount;
+                                apr_byte_t bytes[8];
+                        } bitcount;
+                        bitcount.bitcount = context->bitcount;
+                        MEMCPY_BCOPY(&context->buffer[SHA256_SHORT_BLOCK_LENGTH],
bitcount.bytes, 8);
+                }
 
                 /* Final transform: */
                 apr__SHA256_Transform(context, (sha2_word32*)context->buffer);



Mime
View raw message