Skip to content

bpo-43086: Added handling for excess data in binascii.a2b_base64 #24402

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

Merged
merged 26 commits into from
Jul 19, 2021
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
52d83e9
Added handling for excess data in binascii.a2b_base64
idan22moral Jan 31, 2021
557bce8
📜🤖 Added by blurb_it.
blurb-it[bot] Jan 31, 2021
6ed5193
Added if-state guard
idan22moral Mar 13, 2021
4ee90f5
Merge branch 'master' of https://github.com/idan22moral/cpython
idan22moral Mar 30, 2021
c7b723f
Implemented the strict mode logic
idan22moral Mar 30, 2021
93f497a
Merge branch 'master' of https://github.com/python/cpython
idan22moral Mar 30, 2021
f6283d9
Trying to fix the "Check if generated files are up to date" failure
idan22moral Apr 7, 2021
cedbb85
Generated function signatures using clinic
idan22moral Apr 7, 2021
69c96d5
Handle data in the middle of the padding in strict mode
idan22moral Apr 12, 2021
3718ebd
Added a test for strict mode
idan22moral Apr 12, 2021
d0b60e2
Added a test for invalid data as the first character
idan22moral Jul 10, 2021
afb95db
Disallowed leading padding in strict mode
idan22moral Jul 10, 2021
3c5758b
Added tests for padding-only input
idan22moral Jul 10, 2021
5f8df5b
Added tests to validate the default behavior.
idan22moral Jul 10, 2021
644dbaf
Described the changed of this pull request
idan22moral Jul 10, 2021
464484c
Modified syntax of RST
idan22moral Jul 10, 2021
e1ccf8a
Updated the docs to explain the strict_mode parameter
idan22moral Jul 10, 2021
d6a5cbf
Moved declaration of state to the beginning to prevent multiple decla…
idan22moral Jul 16, 2021
5abc68f
Merge branch 'main' into master
idan22moral Jul 16, 2021
08aa26c
Corrected the RST syntax for argument in docs (italic)
idan22moral Jul 16, 2021
2f1990e
Corrected the RST syntax for argument in news (italic)
idan22moral Jul 16, 2021
fa959bd
Removed whitespace that lead to build failure
idan22moral Jul 16, 2021
a60a8c6
use self.assertEqual instead of assert ==
gpshead Jul 18, 2021
0307272
remove leadg `| ` characters in NEWS
gpshead Jul 18, 2021
d26e1eb
Simplify the error messages.
gpshead Jul 18, 2021
652e7f4
update test for error message (Leading vs Malformed)
gpshead Jul 18, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Added handling for excess data in binascii.a2b_base64
13 changes: 10 additions & 3 deletions Modules/binascii.c
Original file line number Diff line number Diff line change
Expand Up @@ -466,10 +466,16 @@ binascii_a2b_base64_impl(PyObject *module, Py_buffer *data)
*/
if (this_ch == BASE64_PAD) {
if (quad_pos >= 2 && quad_pos + ++pads >= 4) {
/* A pad sequence means no more input.
** We've already interpreted the data
** from the quad at this point.
/* A pad sequence means we should not parse more input.
** We've already interpreted the data from the quad at this point.
** An error should raise if there's excess data after the padding.
*/
if (i + 1 < ascii_len) {
binascii_state *state = PyModule_GetState(module);
PyErr_SetString(state->Error, "Excess data after padding is not allowed");
goto error_end;
}

goto done;
}
continue;
Expand Down Expand Up @@ -522,6 +528,7 @@ binascii_a2b_base64_impl(PyObject *module, Py_buffer *data)
} else {
PyErr_SetString(state->Error, "Incorrect padding");
}
error_end:
_PyBytesWriter_Dealloc(&writer);
return NULL;
}
Expand Down