diff options
author | Idan Moral <idan22moral@gmail.com> | 2021-07-19 22:42:19 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-07-19 22:42:19 (GMT) |
commit | 366fcbac18e3adc41e3901580dbedb6a91e41a10 (patch) | |
tree | 0abd9419519cb97908c0aa83229f03605ceae571 /Modules | |
parent | e25e43e3556db782b51e96f7da4207c4d7914b1e (diff) | |
download | cpython-366fcbac18e3adc41e3901580dbedb6a91e41a10.zip cpython-366fcbac18e3adc41e3901580dbedb6a91e41a10.tar.gz cpython-366fcbac18e3adc41e3901580dbedb6a91e41a10.tar.bz2 |
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
Diffstat (limited to 'Modules')
-rw-r--r-- | Modules/binascii.c | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/Modules/binascii.c b/Modules/binascii.c index 50f25b4..e80eb2a 100644 --- a/Modules/binascii.c +++ b/Modules/binascii.c @@ -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; |