diff options
author | Tim Potter <tpot@samba.org> | 2004-09-19 08:58:56 +0000 |
---|---|---|
committer | Gerald (Jerry) Carter <jerry@samba.org> | 2007-10-10 12:58:50 -0500 |
commit | 6bc08531b22895cf7ac7c0579a9445491b315b18 (patch) | |
tree | 4204dfa02e1a7f9c23e427df39f2927c03855253 /source4/scripting/swig/dcerpc.i | |
parent | d384984e3541a527f36174459714a5f0cdbd8182 (diff) | |
download | samba-6bc08531b22895cf7ac7c0579a9445491b315b18.tar.gz samba-6bc08531b22895cf7ac7c0579a9445491b315b18.tar.bz2 samba-6bc08531b22895cf7ac7c0579a9445491b315b18.zip |
r2416: More argument checks. Raise an exception instead of segfaulting if a
dictionary does not contain a required key.
(This used to be commit fc5443af9c271baf189ebe0b098e190b5eda4e14)
Diffstat (limited to 'source4/scripting/swig/dcerpc.i')
-rw-r--r-- | source4/scripting/swig/dcerpc.i | 42 |
1 files changed, 41 insertions, 1 deletions
diff --git a/source4/scripting/swig/dcerpc.i b/source4/scripting/swig/dcerpc.i index a09c3f2377..a90ac90b5a 100644 --- a/source4/scripting/swig/dcerpc.i +++ b/source4/scripting/swig/dcerpc.i @@ -51,6 +51,11 @@ void set_ntstatus_exception(int status) uint8 uint8_from_python(PyObject *obj, char *name) { + if (obj == NULL) { + PyErr_Format(PyExc_ValueError, "Expecting key %s", name); + return 0; + } + if (!PyInt_Check(obj)) { PyErr_Format(PyExc_TypeError, "Expecting int value for %s", name); return 0; @@ -66,6 +71,11 @@ PyObject *uint8_to_python(uint8 obj) uint16 uint16_from_python(PyObject *obj, char *name) { + if (obj == NULL) { + PyErr_Format(PyExc_ValueError, "Expecting key %s", name); + return 0; + } + if (!PyInt_Check(obj)) { PyErr_Format(PyExc_TypeError, "Expecting int value for %s", name); return 0; @@ -81,6 +91,11 @@ PyObject *uint16_to_python(uint16 obj) uint32 uint32_from_python(PyObject *obj, char *name) { + if (obj == NULL) { + PyErr_Format(PyExc_ValueError, "Expecting key %s", name); + return 0; + } + if (!PyInt_Check(obj)) { PyErr_Format(PyExc_TypeError, "Expecting int value for %s", name); return 0; @@ -96,6 +111,11 @@ PyObject *uint32_to_python(uint32 obj) int64 int64_from_python(PyObject *obj, char *name) { + if (obj == NULL) { + PyErr_Format(PyExc_ValueError, "Expecting key %s", name); + return 0; + } + if (!PyInt_Check(obj)) { PyErr_Format(PyExc_TypeError, "Expecting int value for %s", name); return 0; @@ -111,6 +131,11 @@ PyObject *int64_to_python(int64 obj) uint64 uint64_from_python(PyObject *obj, char *name) { + if (obj == NULL) { + PyErr_Format(PyExc_ValueError, "Expecting key %s", name); + return 0; + } + if (!PyInt_Check(obj)) { PyErr_Format(PyExc_TypeError, "Expecting int value for %s", name); return 0; @@ -126,6 +151,11 @@ PyObject *uint64_to_python(uint64 obj) NTTIME NTTIME_from_python(PyObject *obj, char *name) { + if (obj == NULL) { + PyErr_Format(PyExc_ValueError, "Expecting key %s", name); + return 0; + } + if (!PyInt_Check(obj)) { PyErr_Format(PyExc_TypeError, "Expecting integer value for %s", name); return 0; @@ -141,6 +171,11 @@ PyObject *NTTIME_to_python(NTTIME obj) HYPER_T HYPER_T_from_python(PyObject *obj, char *name) { + if (obj == NULL) { + PyErr_Format(PyExc_ValueError, "Expecting key %s", name); + return 0; + } + if (!PyInt_Check(obj)) { PyErr_Format(PyExc_TypeError, "Expecting integer value for %s", name); return 0; @@ -159,12 +194,17 @@ PyObject *HYPER_T_to_python(HYPER_T obj) char *string_ptr_from_python(TALLOC_CTX *mem_ctx, PyObject *obj, char *name) { + if (obj == NULL) { + PyErr_Format(PyExc_ValueError, "Expecting key %s", name); + return NULL; + } + if (obj == Py_None) return NULL; if (!PyString_Check(obj)) { PyErr_Format(PyExc_TypeError, "Expecting string value for %s", name); - return 0; + return NULL; } return PyString_AsString(obj); |