Skip to content
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

Avoid overflow in DAB Monobit2 test. #24

Merged
merged 1 commit into from
Apr 6, 2024

Conversation

mbroz
Copy link
Contributor

@mbroz mbroz commented Apr 6, 2024

With default ntup 0, the DAB Monobit 2 test tries to select maximum block, but only up to the fixed BLOCK_MAX.

User can override the test with ntup value (-n option) but as there are fixed allocation of pvalues, only values up to BLOCK_MAX-1 (15) are allowed.
(Increasing BLOCK_MAX would cause malloc to fail anyway.)

Skipping automatic block size detection could also cause test to fail if there is not enough samples.

Fix possible overflow by exiting the program with
an error message as there is no proper invalid return code check (as seen in other tests too).

Segfault/overflow easily reproducible with
truncate -s 256M test.img
dieharder/dieharder -n 32 -d 209 -g 201 -f test.img

With default ntup 0, the DAB Monobit 2 test tries to select
maximum block, but only up to the fixed BLOCK_MAX.

User can override the test with ntup value (-n option) but
as there are fixed allocation of pvalues, only values up
to BLOCK_MAX-1 (15) are allowed.
(Increasing BLOCK_MAX would cause malloc to fail anyway.)

Skipping automatic block size detection could also cause
test to fail if there is not enough samples.

Fix possible overflow by exiting the program with
an error message as there is no proper invalid return
code check (as seen in other tests too).

Segfault/overflow easily reproducible with
  truncate -s 256M test.img
  dieharder/dieharder -n 32 -d 209 -g 201 -f test.img
Copy link
Owner

@eddelbuettel eddelbuettel left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me. Thanks as always

@eddelbuettel eddelbuettel merged commit 3442896 into eddelbuettel:master Apr 6, 2024
1 check passed
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