[Pkg-swan-devel] [strongswan] 04/05: Cherry-pick 701d6ed and 1c70c6e from upstream to fix big-endian FTBFS

Romain Francoise rfrancoise at moszumanska.debian.org
Wed Oct 22 19:42:20 UTC 2014


This is an automated email from the git hooks/post-receive script.

rfrancoise pushed a commit to branch master
in repository strongswan.

commit e3d5da3e7b7113f4fe25bdd3a326a06e46811d69
Author: Romain Francoise <rfrancoise at debian.org>
Date:   Wed Oct 22 21:16:28 2014 +0200

    Cherry-pick 701d6ed and 1c70c6e from upstream to fix big-endian FTBFS
---
 debian/changelog                         |  4 +-
 debian/patches/02_chunk-endianness.patch | 72 ++++++++++++++++++++++++++++++++
 debian/patches/series                    |  1 +
 3 files changed, 76 insertions(+), 1 deletion(-)

diff --git a/debian/changelog b/debian/changelog
index 273d931..2de2158 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -1,5 +1,7 @@
 strongswan (5.2.1-2) UNRELEASED; urgency=medium
 
+  * Cherry-pick commits 701d6ed and 1c70c6e from upstream to fix checksum
+    computation and FTBFS on big-endian hosts.
   * Run the test suite only on amd64, i386, and s390x. It requires lots of
     entropy and CPU time, which are typically hard to come by on slower
     archs.
@@ -8,7 +10,7 @@ strongswan (5.2.1-2) UNRELEASED; urgency=medium
   * Update Dutch translation, thanks to Frans Spiesschaert (closes: #763798).
   * Bump Standards-Version to 3.9.6.
 
- -- Romain Francoise <rfrancoise at debian.org>  Wed, 22 Oct 2014 21:06:49 +0200
+ -- Romain Francoise <rfrancoise at debian.org>  Wed, 22 Oct 2014 21:16:00 +0200
 
 strongswan (5.2.1-1) unstable; urgency=medium
 
diff --git a/debian/patches/02_chunk-endianness.patch b/debian/patches/02_chunk-endianness.patch
new file mode 100644
index 0000000..f98dfee
--- /dev/null
+++ b/debian/patches/02_chunk-endianness.patch
@@ -0,0 +1,72 @@
+commit 701d6ed7361c4554411f06079816784bc43d6df4
+Author: Tobias Brunner <tobias at strongswan.org>
+Date:   Wed Oct 22 19:41:40 2014 +0200
+
+    chunk: Fix internet checksum calculation on big-endian systems
+    
+    ntohs() might be defined as noop (#define ntohs(x) (x)) so we have
+    to manually shorten the negated value (gets promoted to an int).
+
+diff --git a/src/libstrongswan/utils/chunk.c b/src/libstrongswan/utils/chunk.c
+index 4b24b37..c4471be 100644
+--- a/src/libstrongswan/utils/chunk.c
++++ b/src/libstrongswan/utils/chunk.c
+@@ -992,7 +992,7 @@ u_int32_t chunk_hash_static(chunk_t chunk)
+  */
+ u_int16_t chunk_internet_checksum_inc(chunk_t data, u_int16_t checksum)
+ {
+-	u_int32_t sum = ntohs(~checksum);
++	u_int32_t sum = ntohs((u_int16_t)~checksum);
+ 
+ 	while (data.len > 1)
+ 	{
+
+commit 1c70c6ed275c7701877dbf6322721af38ada2d68
+Author: Tobias Brunner <tobias at strongswan.org>
+Date:   Wed Oct 22 19:43:22 2014 +0200
+
+    unit-tests: Fix internet checksum tests on big-endian systems
+    
+    We actually need to do a byte-swap, which ntohs() only does on
+    little-endian systems.
+
+diff --git a/src/libstrongswan/tests/suites/test_chunk.c b/src/libstrongswan/tests/suites/test_chunk.c
+index d71e010..b5d2365 100644
+--- a/src/libstrongswan/tests/suites/test_chunk.c
++++ b/src/libstrongswan/tests/suites/test_chunk.c
+@@ -787,6 +787,11 @@ END_TEST
+  * test for chunk_internet_checksum[_inc]()
+  */
+ 
++static inline u_int16_t compensate_alignment(u_int16_t val)
++{
++	return ((val & 0xff) << 8) | (val >> 8);
++}
++
+ START_TEST(test_chunk_internet_checksum)
+ {
+ 	chunk_t chunk;
+@@ -804,9 +809,9 @@ START_TEST(test_chunk_internet_checksum)
+ 
+ 	/* need to compensate for even/odd alignment */
+ 	sum = chunk_internet_checksum(chunk_create(chunk.ptr, 9));
+-	sum = ntohs(sum);
++	sum = compensate_alignment(sum);
+ 	sum = chunk_internet_checksum_inc(chunk_create(chunk.ptr+9, 11), sum);
+-	sum = ntohs(sum);
++	sum = compensate_alignment(sum);
+ 	ck_assert_int_eq(0x442e, ntohs(sum));
+ 
+ 	chunk = chunk_from_chars(0x45,0x00,0x00,0x30,0x44,0x22,0x40,0x00,0x80,0x06,
+@@ -821,9 +826,9 @@ START_TEST(test_chunk_internet_checksum)
+ 
+ 	/* need to compensate for even/odd alignment */
+ 	sum = chunk_internet_checksum(chunk_create(chunk.ptr, 9));
+-	sum = ntohs(sum);
++	sum = compensate_alignment(sum);
+ 	sum = chunk_internet_checksum_inc(chunk_create(chunk.ptr+9, 10), sum);
+-	sum = ntohs(sum);
++	sum = compensate_alignment(sum);
+ 	ck_assert_int_eq(0x4459, ntohs(sum));
+ }
+ END_TEST
diff --git a/debian/patches/series b/debian/patches/series
index f069d77..ed4f144 100644
--- a/debian/patches/series
+++ b/debian/patches/series
@@ -1,2 +1,3 @@
 01_fix-manpages.patch
+02_chunk-endianness.patch
 03_systemd-service.patch

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-swan/strongswan.git



More information about the Pkg-swan-devel mailing list