bpo-44678: Separate error message for discontinuous padding in binascii.a2b_base64 strict mode (GH-27249)

* Renamed assertLeadingPadding function to match logic
* Added a separate error message for discontinuous padding
* Updated the tests for discontinuous padding
This commit is contained in:
Idan Moral 2021-07-20 01:42:19 +03:00 committed by GitHub
parent e25e43e355
commit 366fcbac18
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 15 additions and 8 deletions

View file

@ -464,7 +464,6 @@ binascii_a2b_base64_impl(PyObject *module, Py_buffer *data, int strict_mode)
unsigned char *bin_data_start = bin_data;
if (strict_mode && ascii_len > 0 && ascii_data[0] == '=') {
malformed_padding:
state = get_binascii_state(module);
if (state) {
PyErr_SetString(state->Error, "Leading padding not allowed");
@ -516,7 +515,11 @@ binascii_a2b_base64_impl(PyObject *module, Py_buffer *data, int strict_mode)
// Characters that are not '=', in the middle of the padding, are not allowed
if (strict_mode && padding_started) {
goto malformed_padding;
state = get_binascii_state(module);
if (state) {
PyErr_SetString(state->Error, "Discontinuous padding not allowed");
}
goto error_end;
}
pads = 0;