-
Notifications
You must be signed in to change notification settings - Fork 35
Fix the StateBinary.get32 parser #57
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
The multiplicand for the top byte was 1677721 (0x199999) when it should have been 0x1000000. Changed all the multiplicands to hex to make it more obvious that they are correct. This was found by round tripping DNS packets captured with Wireshark.
The old `genTTL` was only generating a subset of `Word32` values (ie [0 .. 0xffffff]) because the round-trop test would fail for values above 0xffffff due of the bug in StateBinary.get32 which has now been fixed.
@@ -125,7 +125,7 @@ get16 = ST.lift getWord16be <* addPosition 2 | |||
getWord16be = do | |||
a <- word8' | |||
b <- word8' | |||
return $ a * 256 + b | |||
return $ a * 0x100 + b |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this a just style change?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, most coders know that 256
is 0x100 but few coders can tell the decimal value of
0x1000000`. Changing this one so its in the same form as the others below.
@@ -136,7 +136,7 @@ get32 = ST.lift getWord32be <* addPosition 4 | |||
b <- word8' | |||
c <- word8' | |||
d <- word8' | |||
return $ a * 1677721 + b * 65536 + c * 256 + d | |||
return $ a * 0x1000000 + b * 0x10000 + c * 0x100 + d |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does this mean that I made a mistake on copying 16777216
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think you know the answer to that :).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for finding this. :-)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for providing this library. Soooo much easier to extend this than starting from scratch.
Merged. |
Found when round-tripping packets captured with Wireshark.