Control: tags -1 fixed 0.153-1
Control: tags -1 - sid
Control: tags -1 + patch

Mark Wielaard <m...@redhat.com> writes:

> On Tue, 2012-08-14 at 09:07 +0200, Lucas Nussbaum wrote:
>> During a rebuild of all packages in *wheezy*, your package failed to
>> build on amd64.
>> 
>> Relevant part:
>> > gcc -D_GNU_SOURCE -DHAVE_CONFIG_H -DLOCALEDIR='"/usr/share/locale"' -I.
>> > -I.. -I. -I. -I../lib -I.. -I./../libelf -std=gnu99 -Wall -Wshadow -Werror
>> > -Wunused -Wextra -fgnu89-inline -Wformat=2 -fpic -g -O2 -MT md5.o -MD -MP
>> > -MF .deps/md5.Tpo -c -o md5.o md5.c
>> > md5.c: In function 'md5_finish_ctx':
>> > md5.c:108:3: error: dereferencing type-punned pointer will break 
>> > strict-aliasing rules [-Werror=strict-aliasing]
>> > md5.c:109:3: error: dereferencing type-punned pointer will break 
>> > strict-aliasing rules [-Werror=strict-aliasing]
>> > cc1: all warnings being treated as errors
>> > make[3]: *** [md5.o] Error 1
>
> This should be fixed in 0.153 (current release is 0.154) by upstream
> commit:
>
> commit 32899ac4f69d4ca4856d5282464c1f9cee928c8a
> Author: Roland McGrath <rol...@hack.frob.com>
> Date:   Sat Jul 9 03:17:24 2011 -0700

Thanks for pointing to that upstream commit.

I attach a patch to elfutils 0.152-1, targeted to
testing-proposed-updates, based on a trimmed down version of the commit.

Regards,
diff -Nru elfutils-0.152/debian/changelog elfutils-0.152/debian/changelog
--- elfutils-0.152/debian/changelog	2011-02-26 15:09:58.000000000 +0100
+++ elfutils-0.152/debian/changelog	2012-09-08 14:34:50.000000000 +0200
@@ -1,3 +1,11 @@
+elfutils (0.152-1+wheezy1) testing-proposed-updates; urgency=low
+
+  * Non-maintainer upload.
+  * strict-aliasing.diff: new patch taken from upstream (Closes: #684825).
+    Thanks to Mark Wielaard for pointing to the relevant upstream commit.
+
+ -- Sébastien Villemot <sebastien.ville...@ens.fr>  Sat, 08 Sep 2012 12:02:15 +0000
+
 elfutils (0.152-1) unstable; urgency=low
 
   * New upstream release
diff -Nru elfutils-0.152/debian/patches/series elfutils-0.152/debian/patches/series
--- elfutils-0.152/debian/patches/series	2011-02-26 15:11:22.000000000 +0100
+++ elfutils-0.152/debian/patches/series	2012-09-08 13:50:38.000000000 +0200
@@ -7,3 +7,4 @@
 do-autoreconf.diff
 testsuite-ignore-elflint.diff
 elf_additions.diff
+strict-aliasing.diff
diff -Nru elfutils-0.152/debian/patches/strict-aliasing.diff elfutils-0.152/debian/patches/strict-aliasing.diff
--- elfutils-0.152/debian/patches/strict-aliasing.diff	1970-01-01 01:00:00.000000000 +0100
+++ elfutils-0.152/debian/patches/strict-aliasing.diff	2012-09-08 14:07:13.000000000 +0200
@@ -0,0 +1,69 @@
+Description: Fix strict aliasing issues in MD5 and SHA1 code
+Origin: upstream, http://git.fedorahosted.org/cgit/elfutils.git/commit/?id=32899ac4f69d4ca4856d5282464c1f9cee928c8a
+Bug-Debian: http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=684825
+Last-Update: 2012-09-08
+---
+This patch header follows DEP-3: http://dep.debian.net/deps/dep3/
+--- a/lib/md5.c
++++ b/lib/md5.c
+@@ -82,6 +82,16 @@
+   return resbuf;
+ }
+ 
++static void
++le64_copy (char *dest, uint64_t x)
++{
++  for (size_t i = 0; i < 8; ++i)
++    {
++      dest[i] = (uint8_t) x;
++      x >>= 8;
++    }
++}
++
+ /* Process the remaining bytes in the internal buffer and the usual
+    prolog according to the standard and write the result to RESBUF.
+ 
+@@ -105,9 +115,10 @@
+   memcpy (&ctx->buffer[bytes], fillbuf, pad);
+ 
+   /* Put the 64-bit file length in *bits* at the end of the buffer.  */
+-  *(md5_uint32 *) &ctx->buffer[bytes + pad] = SWAP (ctx->total[0] << 3);
+-  *(md5_uint32 *) &ctx->buffer[bytes + pad + 4] = SWAP ((ctx->total[1] << 3) |
+-							(ctx->total[0] >> 29));
++  const uint64_t bit_length = ((ctx->total[0] << 3)
++                               + ((uint64_t) ((ctx->total[1] << 3) |
++                                              (ctx->total[0] >> 29)) << 32));
++  le64_copy (&ctx->buffer[bytes + pad], bit_length);
+ 
+   /* Process last bytes.  */
+   md5_process_block (ctx->buffer, bytes + pad + 8, ctx);
+--- a/lib/sha1.c
++++ b/lib/sha1.c
+@@ -83,6 +83,13 @@
+   return resbuf;
+ }
+ 
++static void
++be64_copy (char *dest, uint64_t x)
++{
++  for (size_t i = 8; i-- > 0; x >>= 8)
++    dest[i] = (uint8_t) x;
++}
++
+ /* Process the remaining bytes in the internal buffer and the usual
+    prolog according to the standard and write the result to RESBUF.
+ 
+@@ -106,9 +113,10 @@
+   memcpy (&ctx->buffer[bytes], fillbuf, pad);
+ 
+   /* Put the 64-bit file length in *bits* at the end of the buffer.  */
+-  *(sha1_uint32 *) &ctx->buffer[bytes + pad] = SWAP ((ctx->total[1] << 3) |
+-						     (ctx->total[0] >> 29));
+-  *(sha1_uint32 *) &ctx->buffer[bytes + pad + 4] = SWAP (ctx->total[0] << 3);
++  const uint64_t bit_length = ((ctx->total[0] << 3)
++                               + ((uint64_t) ((ctx->total[1] << 3) |
++                                              (ctx->total[0] >> 29)) << 32));
++  be64_copy (&ctx->buffer[bytes + pad], bit_length);
+ 
+   /* Process last bytes.  */
+   sha1_process_block (ctx->buffer, bytes + pad + 8, ctx);
-- 
 .''`.    Sébastien Villemot
: :' :    Debian Maintainer
`. `'     http://www.dynare.org/sebastien
  `-      GPG Key: 4096R/381A7594

Attachment: pgpEvOPDivwko.pgp
Description: PGP signature

Reply via email to