scroot / gopacket

Automatically exported from code.google.com/p/gopacket
BSD 3-Clause "New" or "Revised" License
0 stars 1 forks source link

Bug in TCP checksum caculation #4

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago

in layers/tcpip.go

  func tcpipChecksum(data []byte, csum uint32) uint16 {
     ....

     if len(data)%2 == 1 {
    csum += uint32(data[length] << 8)
     }

     ....

It should be 

    csum += uint32(data[length]) << 8

Because a byte shift 8bits is 0.
I found this bug when my packet can't pass windows tcp/ip stack.
and wireshark found checksum invalid.

in file `c.pkt`. the correct checksum is a73a. before modify code is b13a.

Original issue reported on code.google.com by cfanfrank@gmail.com on 5 Nov 2013 at 2:07

Attachments:

GoogleCodeExporter commented 9 years ago
Think this should be fixed.  Please reopen if it's not.

Original comment by gconnell@google.com on 5 Nov 2013 at 4:45