-
Notifications
You must be signed in to change notification settings - Fork 481
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
Split encoding into floating and integer functions #677
base: main
Are you sure you want to change the base?
Conversation
I've verified the conversions of the coordinates in the CSV file to the changed generated codes, and the new codes look correct. I'm going to update them - this will break all other implementations until I get around to them one by one. |
@bocops @fulldecent @rsramek would appreciate if you could take a look at the change please, my C isn't that hot. |
while (lng < 0) { | ||
lng += 2 * OLC_kLonMaxDegrees * kGridLonPrecisionInverse; | ||
} | ||
while (lng >= 2 * OLC_kLonMaxDegrees * kGridLonPrecisionInverse) { |
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.
This while loop is a DDOS security vulnerability with large input numbers.
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.
Can address DDOS and otherwise looks good
Issue #672
This splits the C encoding function into a public function that takes doubles, and one that takes integers.
It explicitly rounds multiplying the degrees by the precision. This will cause a small number of encoding tests to require correcting the codes.
The issue was that the C code:
and
didn't always produce the same result. In the first, it truncates the value of
degrees * precision
, in the second it appears to (mostly) round it before adding it.