Package: galera-3
Version: 25.3.19-2
Severity: normal
Tags: patch
User: ubuntu-de...@lists.ubuntu.com
Usertags: origin-ubuntu zesty ubuntu-patch

Dear maintainer,

The galera-3 package was failing to build from source on armhf in Ubuntu,
because the Ubuntu armhf autobuilders expose unaligned accesses as SIGBUS
and galera-3's code makes an unaligned access that gets caught by the test
suite.

Please find attached a fix for this portability bug.

Thanks,
-- 
Steve Langasek                   Give me a lever long enough and a Free OS
Debian Developer                   to set it on, and I can move the world.
Ubuntu Developer                                    http://www.debian.org/
slanga...@ubuntu.com                                     vor...@debian.org
diff -Nru galera-3-25.3.19/debian/patches/fix-unaligned-checksum.patch galera-3-25.3.19/debian/patches/fix-unaligned-checksum.patch
--- galera-3-25.3.19/debian/patches/fix-unaligned-checksum.patch	1969-12-31 16:00:00.000000000 -0800
+++ galera-3-25.3.19/debian/patches/fix-unaligned-checksum.patch	2017-02-20 16:35:16.000000000 -0800
@@ -0,0 +1,28 @@
+Description: avoid unaligned dereferencing of a byte array
+ The checksum verification code casts from memory at an arbitrary offset of
+ a byte array to a uint64_t*, then dereferences it.  This is non-portable
+ because it results in unaligned access.
+ .
+ Work around this by just reading byte-for-byte and bitshifting into the
+ result.
+Author: Steve Langasek <steve.langa...@ubuntu.com>
+
+Index: galera-3-25.3.19/galera/src/write_set_ng.cpp
+===================================================================
+--- galera-3-25.3.19.orig/galera/src/write_set_ng.cpp
++++ galera-3-25.3.19/galera/src/write_set_ng.cpp
+@@ -165,9 +165,11 @@ WriteSetNG::Header::Checksum::verify (Ve
+ 
+     compute (ptr, csize, check);
+ 
+-    hcheck = *(reinterpret_cast<const type_t*>(
+-                   reinterpret_cast<const gu::byte_t*>(ptr) + csize
+-                   ));
++    for (unsigned int i = 0; i < sizeof(type_t); i++) {
++        hcheck += static_cast<type_t>(
++                      reinterpret_cast<const gu::byte_t*>(ptr)[csize+i]
++                  ) << 8*i;
++    }
+ 
+     if (gu_likely(check == hcheck)) return;
+ 
diff -Nru galera-3-25.3.19/debian/patches/series galera-3-25.3.19/debian/patches/series
--- galera-3-25.3.19/debian/patches/series	2016-11-11 11:38:04.000000000 -0800
+++ galera-3-25.3.19/debian/patches/series	2017-02-20 11:16:32.000000000 -0800
@@ -1 +1,2 @@
 fix-openssl-short-read.patch
+fix-unaligned-checksum.patch

Reply via email to