Package: stringencoders
Version: 3.10.3-1
Severity: serious
Tags: upstream patch

Hi,

stringencoders fails to build from source on some platforms, including armel,
powerpc and s390 because of bad casting from -1 to 255 in the testsuite:

[...]
make[1]: Leaving directory 
`/build/buildd-stringencoders_3.10.3-1-powerpc-His7AR/stringencoders-3.10.3'
   dh_auto_test -a
make[1]: Entering directory 
`/build/buildd-stringencoders_3.10.3-1-powerpc-His7AR/stringencoders-3.10.3'
test/modp_b16_test.c ........OK (8 tests)
make[1]: *** [unittest] Error 1
dh_auto_test: make -j1 test returned exit code 2
test/modp_b64_test.c .ASSERTION FAILED: test/modp_b64_test.c:34
make[1]: Leaving directory 
`/build/buildd-stringencoders_3.10.3-1-powerpc-His7AR/stringencoders-3.10.3'
make: *** [build-arch] Error 29
dpkg-buildpackage: error: debian/rules build-arch gave error exit status 2
[...]

(See also the buildd logs)

Attaching a patch that fixes this, testing 255 instead of -1 on values that
were originally initialized as 255.

Thanks,

Roland


-- System Information:
Debian Release: wheezy/sid
  APT prefers unstable
  APT policy: (500, 'unstable')
Architecture: i386 (i686)

Kernel: Linux 3.2.0-4-686-pae (SMP w/2 CPU cores)
Locale: LANG=en_US.utf8, LC_CTYPE=en_US.utf8 (charmap=UTF-8)
Shell: /bin/sh linked to /bin/bash
Description: Fix compile error on some platforms
 stringencoders fails to build from source on some platforms, including armel,
 powerpc and s390 because of bad casting from -1 to 255 in the testsuite. This
 patch fixes this, testing 255 instead of -1 on values that were originally
 initialized as 255.
Author: Roland Stigge <sti...@antcom.de>

---
 test/modp_b64_test.c |   18 +++++++++---------
 test/modp_b85_test.c |   12 ++++++------
 2 files changed, 15 insertions(+), 15 deletions(-)

--- stringencoders-3.10.3.orig/test/modp_b64_test.c
+++ stringencoders-3.10.3/test/modp_b64_test.c
@@ -16,7 +16,7 @@ static char* testEndian()
 {
     // this test that "1" is "AAAB"
     char buf[100];
-    char result[10];
+    unsigned char result[10];
     char endian[] = {(char)0, (char)0, (char)1};
     int d = modp_b64_encode(buf, endian, 3);
     mu_assert_int_equals(4, d);
@@ -31,7 +31,7 @@ static char* testEndian()
     mu_assert_int_equals(0, result[0]);
     mu_assert_int_equals(0, result[1]);
     mu_assert_int_equals(1, result[2]);
-    mu_assert_int_equals(-1, result[3]);
+    mu_assert_int_equals(255, result[3]);
 
     return 0;
 }
@@ -70,7 +70,7 @@ static char* testPadding()
     char msg[100];
     const char ibuf[6] = {1,1,1,1,1,1};
     char obuf[10];
-    char rbuf[10];
+    unsigned char rbuf[10];
     int d = 0;
 
     // 1 in, 4 out
@@ -83,7 +83,7 @@ static char* testPadding()
     d = modp_b64_decode(rbuf, obuf, d);
     mu_assert_int_equals_msg(msg, 1, d);
     mu_assert_int_equals(1, rbuf[0]);
-    mu_assert_int_equals(-1, rbuf[1]);
+    mu_assert_int_equals(255, rbuf[1]);
 
     // 2 in, 4 out
     memset(obuf, 255, sizeof(obuf));
@@ -96,7 +96,7 @@ static char* testPadding()
     mu_assert_int_equals_msg(msg, 2, d);
     mu_assert_int_equals_msg(msg, 1, rbuf[0]);
     mu_assert_int_equals_msg(msg, 1, rbuf[1]);
-    mu_assert_int_equals_msg(msg, -1, rbuf[2]);
+    mu_assert_int_equals_msg(msg, 255, rbuf[2]);
 
     // 3 in, 4 out
     memset(obuf, 255, sizeof(obuf));
@@ -110,7 +110,7 @@ static char* testPadding()
     mu_assert_int_equals_msg(msg, 1, rbuf[0]);
     mu_assert_int_equals_msg(msg, 1, rbuf[1]);
     mu_assert_int_equals_msg(msg, 1, rbuf[2]);
-    mu_assert_int_equals_msg(msg, -1, rbuf[3]);
+    mu_assert_int_equals_msg(msg, 255, rbuf[3]);
 
     // 4 in, 8 out
     memset(obuf, 255, sizeof(obuf));
@@ -125,7 +125,7 @@ static char* testPadding()
     mu_assert_int_equals(1, rbuf[1]);
     mu_assert_int_equals(1, rbuf[2]);
     mu_assert_int_equals(1, rbuf[3]);
-    mu_assert_int_equals(-1, rbuf[4]);
+    mu_assert_int_equals(255, rbuf[4]);
 
     // 5 in, 8 out
     memset(obuf, 255, sizeof(obuf));
@@ -141,7 +141,7 @@ static char* testPadding()
     mu_assert_int_equals(1, rbuf[2]);
     mu_assert_int_equals(1, rbuf[3]);
     mu_assert_int_equals(1, rbuf[4]);
-    mu_assert_int_equals(-1, rbuf[5]);
+    mu_assert_int_equals(255, rbuf[5]);
 
     // 6 in, 8 out
     memset(obuf, 255, sizeof(obuf));
@@ -158,7 +158,7 @@ static char* testPadding()
     mu_assert_int_equals(1, rbuf[3]);
     mu_assert_int_equals(1, rbuf[4]);
     mu_assert_int_equals(1, rbuf[5]);
-    mu_assert_int_equals(-1, rbuf[6]);
+    mu_assert_int_equals(255, rbuf[6]);
 
     return 0;
 }
--- stringencoders-3.10.3.orig/test/modp_b85_test.c
+++ stringencoders-3.10.3/test/modp_b85_test.c
@@ -16,7 +16,7 @@ static char* testEndian()
 {
     // this test that "1" is "!!!!#"
     char buf[100];
-    char result[10];
+    unsigned char result[10];
     char endian[] = {(char)0, (char)0, (char)0, (char)1};
     int d = modp_b85_encode(buf, endian, 4);
     mu_assert_int_equals(5, d);
@@ -33,7 +33,7 @@ static char* testEndian()
     mu_assert_int_equals(0, result[1]);
     mu_assert_int_equals(0, result[2]);
     mu_assert_int_equals(1, result[3]);
-    mu_assert_int_equals(-1, result[4]);
+    mu_assert_int_equals(255, result[4]);
 
     return 0;
 }
@@ -83,9 +83,9 @@ static char* testBadCharDecode()
 
 static char* testEncodeDecode()
 {
-    char ibuf[10]; /* input */
-    char obuf[10]; /* output */
-    char rbuf[10]; /* final result */
+    unsigned char ibuf[10]; /* input */
+    unsigned char obuf[10]; /* output */
+    unsigned char rbuf[10]; /* final result */
     int d;
     int i,j,k,l;
     for (i = 0; i < 256; ++i) {
@@ -107,7 +107,7 @@ static char* testEncodeDecode()
                     mu_assert_int_equals(ibuf[1], rbuf[1]);
                     mu_assert_int_equals(ibuf[2], rbuf[2]);
                     mu_assert_int_equals(ibuf[3], rbuf[3]);
-                    mu_assert_int_equals(-1, rbuf[4]);
+                    mu_assert_int_equals(255, rbuf[4]);
                 }
             }
         }

Reply via email to