From ea54214002c09eeb4dd498d97a564471ec9993c5 Mon Sep 17 00:00:00 2001 From: David Kalnischkies Date: Tue, 13 Sep 2011 10:09:00 +0200 Subject: reorder includes: add if needed and include it at first --- apt-pkg/contrib/sha2_internal.cc | 1 + 1 file changed, 1 insertion(+) (limited to 'apt-pkg/contrib/sha2_internal.cc') diff --git a/apt-pkg/contrib/sha2_internal.cc b/apt-pkg/contrib/sha2_internal.cc index 565db2f91..ff995cdf2 100644 --- a/apt-pkg/contrib/sha2_internal.cc +++ b/apt-pkg/contrib/sha2_internal.cc @@ -31,6 +31,7 @@ * * $Id: sha2.c,v 1.1 2001/11/08 00:01:51 adg Exp adg $ */ +#include #include /* memcpy()/memset() or bcopy()/bzero() */ #include /* assert() */ -- cgit v1.2.3 From 1f8fe502967c41a811c50c9f07454239665047f8 Mon Sep 17 00:00:00 2001 From: David Kalnischkies Date: Sun, 30 Oct 2011 14:17:09 -0500 Subject: * apt-pkg/contrib/sha2_internal.cc: - use a pointer-union to peace gcc strict-aliasing warning --- apt-pkg/contrib/sha2_internal.cc | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) (limited to 'apt-pkg/contrib/sha2_internal.cc') diff --git a/apt-pkg/contrib/sha2_internal.cc b/apt-pkg/contrib/sha2_internal.cc index ff995cdf2..6d27e8f2b 100644 --- a/apt-pkg/contrib/sha2_internal.cc +++ b/apt-pkg/contrib/sha2_internal.cc @@ -605,7 +605,12 @@ void SHA256_Final(sha2_byte digest[], SHA256_CTX* context) { *context->buffer = 0x80; } /* Set the bit count: */ - *(sha2_word64*)&context->buffer[SHA256_SHORT_BLOCK_LENGTH] = context->bitcount; + union { + sha2_byte* c; + sha2_word64* l; + } bitcount; + bitcount.c = &context->buffer[SHA256_SHORT_BLOCK_LENGTH]; + *(bitcount.l) = context->bitcount; /* Final transform: */ SHA256_Transform(context, (sha2_word32*)context->buffer); @@ -922,8 +927,13 @@ static void SHA512_Last(SHA512_CTX* context) { *context->buffer = 0x80; } /* Store the length of input data (in bits): */ - *(sha2_word64*)&context->buffer[SHA512_SHORT_BLOCK_LENGTH] = context->bitcount[1]; - *(sha2_word64*)&context->buffer[SHA512_SHORT_BLOCK_LENGTH+8] = context->bitcount[0]; + union { + sha2_byte* c; + sha2_word64* l; + } bitcount; + bitcount.c = &context->buffer[SHA512_SHORT_BLOCK_LENGTH]; + bitcount.l[0] = context->bitcount[1]; + bitcount.l[1] = context->bitcount[0]; /* Final transform: */ SHA512_Transform(context, (sha2_word64*)context->buffer); -- cgit v1.2.3