X-Git-Url: https://git.distorted.org.uk/~mdw/catacomb-python/blobdiff_plain/8fa9935b741f2c41c0e58be30d5c22d3d0eff7f7..1c6b925f0cf913ce3100c2ae3bcaed26a3f34bc1:/buffer.c diff --git a/buffer.c b/buffer.c index 4160638..bd5e334 100644 --- a/buffer.c +++ b/buffer.c @@ -112,7 +112,8 @@ end: uint##n x; \ if (!PyArg_ParseTuple(arg, ":getu" #w)) goto end; \ if (buf_getu##w(BUF_B(me), &x)) BUFERR(); \ - return (getulong(x)); \ + if (MASK##W <= ULONG_MAX) return (getulong(x)); \ + else { kludge64 y; ASSIGN64(y, x); return (getk64(y)); } \ end: \ return (0); \ } @@ -405,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_) @@ -501,7 +506,7 @@ static PyMethodDef wbuf_pymethods[] = { BUF_DOSUFFIXES(WBMETH_DECL_PUTBLK_) METH (putmp, "WBUF.putmp(X)") METH (putgf, "WBUF.putgf(X)") - KWMETH(putecpt, "WBUF.putecpt(P)") + METH (putecpt, "WBUF.putecpt(P)") METH (putecptraw, "WBUF.putecptraw(P)") METH (putge, "WBUF.putge(X)") METH (putgeraw, "WBUF.putgeraw(X)")