tag  623634 patch
thanks

On Mon, Mar 31, 2014 at 08:34:03PM +0200, gregor herrmann wrote:
> On Wed, 26 Mar 2014 09:07:40 +0100, Christoph Pleger wrote:
> 
> > On my search in the web, if there was already some solution for 'my'
> > libnet-rawip-perl problem, I found two patches; these are attached. The
> > patch Net-RawIP-0.23-format.patch (from Redhat/Fedora) removes that format
> > problem; the patch nonreturn-in-nonvoid.patch (from OpenSuse) adds a
> > missing default:-part in a switch-statement.

> > Additionally, I attached a patch cc.patch for setting gcc-4.6 as compiler.
> > Of course, gcc-4.6 must be added to Build-Depends.
> 
> I don't think that's the correct way to solve this issue; first it
> only papers over the problem, and second I don't think we'll have
> gcc-4.6 in Debian for much longer.

The problem is ip_in_cksum() in util.c, which starts with

    register long sum = 0;  /* assumes long == 32 bits */

That assumption isn't correct on 64-bit architectures and apparently
breaks with newer gcc versions at -O2 (-O0 still works OK.)

Minimal patch attached, but there may well be other similar problems
lurking. I wonder how well this module works on big endian (particularly
64 bit big endian!) systems.
-- 
Niko Tyni   nt...@debian.org
>From 26689a1e3b67d6577e22d94583f01cda48c1d78e Mon Sep 17 00:00:00 2001
From: Niko Tyni <nt...@debian.org>
Date: Mon, 31 Mar 2014 22:45:03 +0300
Subject: [PATCH] Use the U32 type instead of long to fix problems on 64-bit
 architectures

This fixes packet checksums on 64-bit architectures with
newer gcc versions at optimization level -O2.

This is only the minimal fix; there may be other similar cases left.
---
 util.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/util.c b/util.c
index 762e448..b101719 100644
--- a/util.c
+++ b/util.c
@@ -38,15 +38,15 @@
 unsigned short ip_in_cksum(struct iphdr *iph, unsigned short *ptr, int nbytes)
 {
 
-	register long sum = 0;	/* assumes long == 32 bits */
+	register U32 sum = 0;
 	u_short oddbyte;
 	register u_short answer;	/* assumes u_short == 16 bits */
 	int pheader_len;
 	unsigned short *pheader_ptr;
 	
 	struct pseudo_header {
-		unsigned long saddr;
-		unsigned long daddr;
+		U32 saddr;
+		U32 daddr;
 		unsigned char null;
 		unsigned char proto;
 		unsigned short tlen;
-- 
1.9.1

Reply via email to