From: Douglas Bagnall Date: Thu, 7 Feb 2019 04:04:43 +0000 (+1300) Subject: s3/libsmb/py: match input argument types with C types X-Git-Tag: ldb-1.6.1~202 X-Git-Url: http://git.samba.org/samba.git/?p=nivanova%2Fsamba-autobuild%2F.git;a=commitdiff_plain;h=96cdacae1475847fa5005370a4fcb5fcacfb4dbc;hp=8294e68a4175e6116b38869866c42a1b7ba55b6a s3/libsmb/py: match input argument types with C types If PyArg_ParseTupleAndKeywords() is given, say, an "H" format (meaning unsigned short int) but the referenced variable is a plain unsigned int, the top 16 bits of the variable will be left undefined. In that case we should use an "I" format (and/or initialize the variable). In many cases the change is fairly innocuous, such as when "i" and "I" are mixed (for signed and unsigned ints respectively), but the resulting write is the same size and probably gives the same result in practice. Signed-off-by: Douglas Bagnall Reviewed-by: Noel Power --- diff --git a/source3/libsmb/pylibsmb.c b/source3/libsmb/pylibsmb.c index 5f3e6a8c724..da2e5e12d0d 100644 --- a/source3/libsmb/pylibsmb.c +++ b/source3/libsmb/pylibsmb.c @@ -856,7 +856,7 @@ static PyObject *py_cli_write(struct py_cli_state *self, PyObject *args, "fnum", "buffer", "offset", "mode", NULL }; if (!ParseTupleAndKeywords( - args, kwds, "I" PYARG_BYTES_LEN "K|I", kwlist, + args, kwds, "i" PYARG_BYTES_LEN "K|I", kwlist, &fnum, &buf, &buflen, &offset, &mode)) { return NULL; } @@ -1012,7 +1012,7 @@ static PyObject *py_cli_read(struct py_cli_state *self, PyObject *args, "fnum", "offset", "size", NULL }; if (!ParseTupleAndKeywords( - args, kwds, "IKI", kwlist, &fnum, &offset, + args, kwds, "iKI", kwlist, &fnum, &offset, &size)) { return NULL; } @@ -1230,7 +1230,7 @@ static PyObject *py_cli_list(struct py_cli_state *self, PyObject *result = NULL; const char *kwlist[] = { "directory", "mask", "attribs", NULL }; - if (!ParseTupleAndKeywords(args, kwds, "z|sH:list", kwlist, + if (!ParseTupleAndKeywords(args, kwds, "z|sI:list", kwlist, &base_dir, &user_mask, &attribute)) { return NULL; }