gh-148093: Raise binascii.Error from binascii.a2b_uu on empty input#149077
gh-148093: Raise binascii.Error from binascii.a2b_uu on empty input#149077serhiy-storchaka merged 6 commits intopython:mainfrom
binascii.Error from binascii.a2b_uu on empty input#149077Conversation
| self.assertRaises(binascii.Error, binascii.a2b_uu, b"!!!!") | ||
| self.assertRaises(binascii.Error, binascii.a2b_uu, | ||
| self.type2test(b"")) | ||
| self.assertRaises(binascii.Error, binascii.a2b_uu, |
There was a problem hiding this comment.
Do we need this second test case? The [:0] makes it an empty sequence?
There was a problem hiding this comment.
cpython/Lib/test/test_binascii.py
Lines 1622 to 1623 in 005555a
memoryview(b"#86)C")[:0] is the actual UB case here: zero slice with larger underlying buffer
@serhiy-storchaka came up with it:
Truth to be told, this BinASCIITest inheritance is very confusing and make lots of tests without self.type2test redundant but I didn't want to overhaul it. Do you want me to create a separate issue documenting problems with BinASCIITest?
There was a problem hiding this comment.
BTW, #86)C is a uuencoded b'abc', the simplest non-trivial example. It has no any relation to the current, the past or the future US presidents.
| self.assertRaises(binascii.Error, binascii.a2b_uu, b"!!!!") | ||
| self.assertRaises(binascii.Error, binascii.a2b_uu, | ||
| self.type2test(b"")) | ||
| self.assertRaises(binascii.Error, binascii.a2b_uu, |
There was a problem hiding this comment.
BTW, #86)C is a uuencoded b'abc', the simplest non-trivial example. It has no any relation to the current, the past or the future US presidents.
|
Thanks @maurycy for the PR, and @serhiy-storchaka for merging it 🌮🎉.. I'm working now to backport this PR to: 3.13. |
|
Thanks @maurycy for the PR, and @serhiy-storchaka for merging it 🌮🎉.. I'm working now to backport this PR to: 3.14. |
|
GH-149349 is a backport of this pull request to the 3.13 branch. |
|
GH-149350 is a backport of this pull request to the 3.14 branch. |
Right now,
binascii.a2b_uuwith empty data reads one byte past the end of the input buffer. Per the discussion, it should raisebinascii.Error.Resolves #148093