From: Mark Wooding Date: Sat, 12 Oct 2019 20:07:05 +0000 (+0100) Subject: buffer.c (wbmeth_putblkN): Check input block size. X-Git-Url: https://git.distorted.org.uk/~mdw/catacomb-python/commitdiff_plain/9fa70ff733c6c962624ae82a46a67a22caebb9b0 buffer.c (wbmeth_putblkN): Check input block size. Otherwise the C code fails an assertion. --- diff --git a/buffer.c b/buffer.c index 17d7caa..27eafd1 100644 --- a/buffer.c +++ b/buffer.c @@ -406,16 +406,20 @@ static PyObject *wbmeth_put(PyObject *me, PyObject *arg) } DOUINTCONV(WBMETH_PUTU_) +#define MASKz 0 #define SZ_z 1 #define WBMETH_PUTBLK_(n, W, w) \ static PyObject *wbmeth_putblk##w(PyObject *me, PyObject *arg) \ { \ char *p; \ Py_ssize_t sz; \ - if (!PyArg_ParseTuple(arg, "s#:putblk" #w, &p, &sz)) return (0); \ + if (!PyArg_ParseTuple(arg, "s#:putblk" #w, &p, &sz)) goto end; \ + if (MASK##W && sz > MASK##W) VALERR("too large"); \ ensure(me, sz + SZ_##n); \ buf_putmem##w(BUF_B(me), p, sz); assert(BOK(BUF_B(me))); \ RETURN_ME; \ + end: \ + return (0); \ } BUF_DOSUFFIXES(WBMETH_PUTBLK_)