[PATCH] checksum problem on big endian systems

Frédéric Raynal <[email protected]>
Newsgroups gmane.comp.security.libnet
Message-ID <[email protected]>
Hi,


A few days ago, Mike reported me a bug hapening on Mac OS X, and
probably with other big endian systems: some checksums were invalid,
sometimes ...

Here is a proposed patch (very short :) but that would be great if you
guys could test it on different systems/arch (eg sparc/solaris). I've
just tested on my OS X and an x86 linux to check it does not insert
a bug.

The problem was in libnet_in_cksum() (libnet_checksum.c) when
packet'size was odd, due to a bad casting and endianess problems.

I suspect this can also affect other places with such casting, but I
had no time to investigate any further.


	Frenchy pal Fred Raynal ;-)
be_checksum.patch (text/plain, 269 B)
--- libnet/src/libnet_checksum.c	Sat Jan  3 21:31:02 2004
+++ libnet-fr/src/libnet_checksum.c	Wed Feb 11 10:22:34 2004
@@ -52,7 +52,7 @@
     }
     if (len == 1)
     {
-        sum += *(u_int8_t *)addr;
+        sum += *(u_int16_t *)addr;
     }
 
     return (sum);
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.