Skip to content

Conversation

erikd
Copy link
Contributor

@erikd erikd commented Jul 1, 2017

Found when round-tripping packets captured with Wireshark.

erikd added 2 commits July 1, 2017 18:05
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.
@erikd erikd force-pushed the topic/fix-get32 branch from acf0aec to b5a7657 Compare July 1, 2017 08:19
@@ -125,7 +125,7 @@ get16 = ST.lift getWord16be <* addPosition 2
getWord16be = do
a <- word8'
b <- word8'
return $ a * 256 + b
return $ a * 0x100 + b
Copy link
Owner

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?

Copy link
Contributor Author

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
Copy link
Owner

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?

Copy link
Contributor Author

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 :).

Copy link
Owner

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. :-)

Copy link
Contributor Author

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.

@kazu-yamamoto kazu-yamamoto merged commit ab3b3fa into kazu-yamamoto:master Jul 3, 2017
@kazu-yamamoto
Copy link
Owner

Merged.
Thank you for your contributions!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants