netcat: fix logic for archs with unsigned chars
authorNick Leverton <nick@leverton.org>
Tue, 20 Jul 2010 06:58:01 +0000 (08:58 +0200)
committerPeter Korsgaard <jacmet@sunsite.dk>
Tue, 20 Jul 2010 06:59:36 +0000 (08:59 +0200)
Closes #2245

Signed-off-by: Nick Leverton <nick@leverton.org>
Signed-off-by: Peter Korsgaard <jacmet@sunsite.dk>
CHANGES
package/netcat/netcat-0.7.1-signed-bit-counting.patch [new file with mode: 0644]

diff --git a/CHANGES b/CHANGES
index 59b4a6fd89fa103738cda6c8169c81ace10ed84b..1386a7732734c2758ad92e526ee65413e3cd25e0 100644 (file)
--- a/CHANGES
+++ b/CHANGES
@@ -21,8 +21,8 @@
        iptables, libart, libcgi, libfuse, libgpg-error, libidn,
        liblockfile, libpng, links, linux-fusion, lmbench, lrzsz,
        make, module-init-tools, mysql_client, nbd, ncurses, neon,
-       netperf, ntfsprogs, openssl, php, qt, quagga, sqlite, sdl,
-       sdl_mixer, sdl_sound, sdl_ttf, squashfs, tn5250, tremor,
+       netcat, netperf, ntfsprogs, openssl, php, qt, quagga, sqlite,
+       sdl, sdl_mixer, sdl_sound, sdl_ttf, squashfs, tn5250, tremor,
        usbutils, xkeyboard-config, xserver_xorg-server, xvkbd
 
        Removed packages: modutils, portage, rxvt
@@ -70,6 +70,7 @@
        #2191: linux-fusion build fail
        #2221: Qt does not compile (dependencies not taken into account?)
        #2233: Atmel atstk target skeletons have /etc/mtab as a file, not ...
+       #2245: Netcat does not work due to incorrect assumptions about signed..
 
 2010.05, Released May 30th, 2010:
 
diff --git a/package/netcat/netcat-0.7.1-signed-bit-counting.patch b/package/netcat/netcat-0.7.1-signed-bit-counting.patch
new file mode 100644 (file)
index 0000000..e29da31
--- /dev/null
@@ -0,0 +1,30 @@
+# Fix the endian-specific bit-counting code so that it works.
+# SF:1068324 "netcat_flag_count() fix"
+#   http://sourceforge.net/tracker/?func=detail&aid=1205729&group_id=52204&atid=466046
+# SF:1205729 "doen't work on arm linux platform":
+#   http://sourceforge.net/tracker/?func=detail&aid=1068324&group_id=52204&atid=466046
+
+Index: netcat-0.7.1/src/flagset.c
+===================================================================
+--- netcat-0.7.1.orig/src/flagset.c    2010-07-19 13:51:46.000000000 +0100
++++ netcat-0.7.1/src/flagset.c 2010-07-19 13:52:27.000000000 +0100
+@@ -134,7 +134,7 @@
+ int netcat_flag_count(void)
+ {
+-  register char c;
++  register unsigned char c;
+   register int i;
+   int ret = 0;
+@@ -154,8 +154,8 @@
+       Assumed that the bit number 1 is the sign, and that we will shift the
+       bit 1 (or the bit that takes its place later) until the the most right,
+       WHY it has to keep the wrong sign? */
+-      ret -= (c >> 7);
+-      c <<= 1;
++      ret += c&1;
++      c>>=1;
+     }
+   }