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

Fix overflows in mzd_init() #28

Merged
merged 1 commit into from
Feb 3, 2025
Merged

Fix overflows in mzd_init() #28

merged 1 commit into from
Feb 3, 2025

Conversation

tornaria
Copy link
Contributor

@tornaria tornaria commented Feb 3, 2025

The multiplication in mzd_init() causes a segfault in sagemath on 32 bit.

A doctest runs MatrixSpace(GF(2), 2^30)(1) expecting to get a memory allocation error, but it doesn't. In fact, the data member ends up with a malloc(0) (not NULL!) which later causes a segfault. All of this because (2^30) * (2^30/64) is 0 when size_t is 32 bits.

While looking at this I also noticed that mzd_init(1, INT_MAX) aborts (on any architecture), due to another overflow which I also fix here.

@malb malb merged commit 2dcecab into malb:master Feb 3, 2025
1 check passed
@malb
Copy link
Owner

malb commented Feb 3, 2025

Ta!

@tornaria tornaria deleted the fix-overflow branch February 3, 2025 22:51
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