Jump to content

Another checksum bug


Stonebone

Recommended Posts

While transfering big files with tftpds i noticed that it seemed to fail systematically. After studying the traffic in ethereal I came to the conclusion that dswifi calculates the checksum for the udp package incorrectly in some rare cases. I read here on the forum that it fails on odd-sized packages but this was an even sized package so it is not the same bug.

 

After spending several hours tracking down this bug, my friend Gustav Munkby and I found the cause of this bug. In a few places in the checksum calculation code similar to this appears:

checksum += checksum>>16;
checksum &= 0xFFFF;

This code is meant to take of the carries from the ones'-complement additions. The correct way of doing this is like this:

while(checksum >> 16) checksum = (checksum & 0xFFFF) + (checksum >> 16);

As an example, if checksum = 0x1FFFF the former code give an incorrect result (0), but the later code will give the correct result (1).

 

I have updated my hacked version to fix this in at least some places:

http://www.itstud.chalmers.se/~larssten/wifi_lib.tar.bz2

Link to comment
Share on other sites

While transfering big files with tftpds i noticed that it seemed to fail systematically. After studying the traffic in ethereal I came to the conclusion that dswifi calculates the checksum for the udp package incorrectly in some rare cases. I read here on the forum that it fails on odd-sized packages but this was an even sized package so it is not the same bug.

 

After spending several hours tracking down this bug, my friend Gustav Munkby and I found the cause of this bug. In a few places in the checksum calculation code similar to this appears:

checksum += checksum>>16;
checksum &= 0xFFFF;

This code is meant to take of the carries from the ones'-complement additions. The correct way of doing this is like this:

while(checksum >> 16) checksum = (checksum & 0xFFFF) + (checksum >> 16);

As an example, if checksum = 0x1FFFF the former code give an incorrect result (0), but the later code will give the correct result (1).

 

I have updated my hacked version to fix this in at least some places:

http://www.itstud.chalmers.se/~larssten/wifi_lib.tar.bz2

 

Hi! Thanks for the feedback, but I had already noticed and fixed this in my working version of the lib (that's what I get for having long delays between releases, I guess) - I do appreciate being informed though :)

 

-Stephen

Link to comment
Share on other sites

Hi! Thanks for the feedback, but I had already noticed and fixed this in my working version of the lib (that's what I get for having long delays between releases, I guess) - I do appreciate being informed though :)

 

-Stephen

Ok well, maybe you should keep the source in a public repository instead. I assume you use something like cvs anyway since it's so convinient even if you are the only programmer. That way you don't need to spend time on doing many intermediate releases. Sourceforge started supporting subversion recently...

Link to comment
Share on other sites

Stonebone: or I can simply not do intermediate releases and make you all wait :unsure:

 

No, really though. I'm more than happy doing this project as I see fit, no need to try to make me change my mind.

 

-Stephen

Link to comment
Share on other sites

i know how you feel sgstairs, dont let comments like these discourage you, do what u seem fit to make this project work, because its the only way its going to get done, Id rather you doing something u love doing the way u love doing it then any other way, gives us a better quality product in the end. I too would like to see a new version, just like the rest of the communiry, but we are finding ways to deal with it till that day comes, so best of luck to ya

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...