summaryrefslogtreecommitdiff
path: root/source3/python
diff options
context:
space:
mode:
authorTim Potter <tpot@samba.org>2002-10-21 04:16:12 +0000
committerTim Potter <tpot@samba.org>2002-10-21 04:16:12 +0000
commit69e2a9d7fa689012848b50b40b7b49eeec536d0a (patch)
treee44a567baa23de6d57d063cdf87dad6ba56dd0ed /source3/python
parent7f62309268bf28dfd44eea23ca4d911742f25e5b (diff)
downloadsamba-69e2a9d7fa689012848b50b40b7b49eeec536d0a.tar.gz
samba-69e2a9d7fa689012848b50b40b7b49eeec536d0a.tar.bz2
samba-69e2a9d7fa689012848b50b40b7b49eeec536d0a.zip
Stricter validation in python->C conversion functions.
(This used to be commit 672c07e2432299e3b1015af524dc5c124f61f904)
Diffstat (limited to 'source3/python')
-rw-r--r--source3/python/py_spoolss_forms_conv.c25
1 files changed, 16 insertions, 9 deletions
diff --git a/source3/python/py_spoolss_forms_conv.c b/source3/python/py_spoolss_forms_conv.c
index 6ef953cbc9..cfeb475b1e 100644
--- a/source3/python/py_spoolss_forms_conv.c
+++ b/source3/python/py_spoolss_forms_conv.c
@@ -57,23 +57,30 @@ BOOL py_to_FORM(FORM *form, PyObject *dict)
{
PyObject *obj, *dict_copy = PyDict_Copy(dict);
char *name;
+ BOOL result = False;
- obj = PyDict_GetItemString(dict, "name");
+ if (!(obj = PyDict_GetItemString(dict_copy, "name")) ||
+ !PyString_Check(obj))
+ goto done;
- if (!obj || !PyString_Check(obj))
- return False;
+ PyDict_DelItemString(dict_copy, "name");
+
+ if (!(obj = PyDict_GetItemString(dict_copy, "level")) ||
+ !PyInt_Check(obj))
+ goto done;
PyDict_DelItemString(dict_copy, "level");
- PyDict_DelItemString(dict_copy, "name");
- if (!to_struct(form, dict_copy, py_FORM)) {
- Py_DECREF(dict_copy);
- return False;
- }
+ if (!to_struct(form, dict_copy, py_FORM))
+ goto done;
name = PyString_AsString(obj);
init_unistr2(&form->name, name, strlen(name) + 1);
- return True;
+ result = True;
+
+done:
+ Py_DECREF(dict_copy);
+ return result;
}