mirror of
https://github.com/python/cpython.git
synced 2025-08-04 00:48:58 +00:00
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.
(cherry picked from commit 3f59b55316
)
Co-authored-by: Zackery Spytz <zspytz@gmail.com>
This commit is contained in:
parent
a729f4abb8
commit
5221a10dde
3 changed files with 15 additions and 0 deletions
|
@ -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);
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue