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.
This commit is contained in:
@@ -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);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user