diff options
author | Zackery Spytz <zspytz@gmail.com> | 2020-05-25 07:55:09 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-05-25 07:55:09 (GMT) |
commit | 3f59b55316f4c6ab451997902579aa69020b537c (patch) | |
tree | 1b3d9129922050565b1ae301916d3e540b81b9ba /Modules/_struct.c | |
parent | 372ee27d4958302dac7ad6a8711f6fd04771b2e6 (diff) | |
download | cpython-3f59b55316f4c6ab451997902579aa69020b537c.zip cpython-3f59b55316f4c6ab451997902579aa69020b537c.tar.gz cpython-3f59b55316f4c6ab451997902579aa69020b537c.tar.bz2 |
bpo-35714: Reject null characters in struct format strings (GH-16928)
struct.error is now raised if there is a null character in a struct
format string.
Diffstat (limited to 'Modules/_struct.c')
-rw-r--r-- | Modules/_struct.c | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/Modules/_struct.c b/Modules/_struct.c index 13d8072..5984bb6 100644 --- a/Modules/_struct.c +++ b/Modules/_struct.c @@ -1296,6 +1296,11 @@ prepare_s(PyStructObject *self) size_t ncodes; fmt = PyBytes_AS_STRING(self->s_format); + if (strlen(fmt) != (size_t)PyBytes_GET_SIZE(self->s_format)) { + PyErr_SetString(_structmodulestate_global->StructError, + "embedded null character"); + return -1; + } f = whichtable(&fmt); |