-
Notifications
You must be signed in to change notification settings - Fork 160
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
Stop out-of-bounds read, and ensure all bytes are used, in FuncIntRandomMT #2716
Conversation
6d75fbe
to
001c4e0
Compare
Codecov Report
@@ Coverage Diff @@
## master #2716 +/- ##
==========================================
+ Coverage 75.75% 75.75% +<.01%
==========================================
Files 478 478
Lines 241451 241459 +8
==========================================
+ Hits 182902 182913 +11
+ Misses 58549 58546 -3
|
001c4e0
to
044db55
Compare
While adding tests (which I should have done in the first place), I found a small bug in this method -- it would round the length of the string down to the nearest multiple of 4, except when the string was of length less than 4. I added a commit which fixes this. This will want to be mentioned in the release notes as it could change random numbers, but only because we are now using the whole string. I could pull this into two PRs if anyone prefers 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.
Can this change "random" numbers? If so that should be noted in the release notes.
The original part of this PR (don't read off the end of bags) wouldn't change random numbers. The second commit (I realised we aren't actually using all the string given) will change random numbers, when generated from a string which satisfies |
I think most such strings would have been obtained by querying the current state of the RNG, and thus its len would have been a multiple of 4. So I think this is fine, but it really should be documented explicitly in the release notes. |
@ChrisJefferson could you please add it to the 4.10 release notes then (in the wiki)? |
done |
This stops FuncIntRandomMT from reading off the end of a bag.
This isn't (currently) an actual problem, as it only reads up to a word-size, which is fine in GASMAN.
This appears to be (based on valgrind testing) the only place where we read a bag in word-sized chunks, where it's not reasonable to make sure the bag is word-sized at construction time.