From b6d75498c5c2765e093db3b1dac2062389395a5b Mon Sep 17 00:00:00 2001 From: Iustin Pop Date: Thu, 5 Dec 2019 21:28:36 +0100 Subject: [PATCH] Change setstate to only take bytes This is the recommended way (well, via Py_buffer, but I don't need that). --- NEWS | 2 ++ acl.c | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/NEWS b/NEWS index 43210c5..94e5183 100644 --- a/NEWS +++ b/NEWS @@ -29,6 +29,8 @@ Important API changes/bug fixes: inadvertently removed due a typo(!) when adding support for it in FreeBSD. Pickle should work again for ACL instances, although not sure how stable this serialisation format actually is. +- Additionally, slightly change `__setstate__()` input to not allow + Unicode, since the serialisation format is an opaque binary format. - Fix (and change) entry qualifier (which is a user/group ID) behaviour: assume/require that uid_t/gid_t are unsigned types (they are with glibc, MacOS and FreeBSD at least; the standard doesn't document the diff --git a/acl.c b/acl.c index e88d143..139d5e5 100644 --- a/acl.c +++ b/acl.c @@ -503,7 +503,7 @@ static PyObject* ACL_set_state(PyObject *obj, PyObject* args) { acl_t ptr; /* Parse the argument */ - if (!PyArg_ParseTuple(args, "s#", &buf, &bufsize)) + if (!PyArg_ParseTuple(args, "y#", &buf, &bufsize)) return NULL; /* Try to import the external representation */ -- 2.39.5