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
mmap.read() crashes when passed a negative argument #50593
Comments
mmap.read() crashes when passed a negative count: def test_read_negative(self):
f = open(TESTFN, 'w+')
f.write("ABCDE\0abcde")
f.flush()
mf = mmap.mmap(f.fileno(), 0)
I don't know what mf.read(-1) should do: raise a ValueError, return the empty |
I think the problem is that mmap uses size_t as length, but uses If mmap should use size_t because it should cover all possible memory |
Well, I would not care that much: you can never read more than |
Hmm, I cannot reproduce the crash. I created the patch experimentally, + if (n < 0) because I don't have so much memory. |
I suggest a comment like: /* The difference can overflow, only if self->size is greater than
|
OK, how about this patch? |
OK for me. |
Thanks, committed in r73677(trunk), r73682(release26-maint), |
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
bugs.python.org fields:
The text was updated successfully, but these errors were encountered: