summaryrefslogtreecommitdiff
path: root/source3
diff options
context:
space:
mode:
authorTim Potter <tpot@samba.org>2002-11-25 00:25:31 +0000
committerTim Potter <tpot@samba.org>2002-11-25 00:25:31 +0000
commit0de32d4533ea6657922b9120824850caeb2785af (patch)
tree199ff989fce9cd9e63ef0c626e8ef992f9b0e253 /source3
parent01063e884577f045eea87bcc441e6edebfff1305 (diff)
downloadsamba-0de32d4533ea6657922b9120824850caeb2785af.tar.gz
samba-0de32d4533ea6657922b9120824850caeb2785af.tar.bz2
samba-0de32d4533ea6657922b9120824850caeb2785af.zip
Fix some argument checking bugs found by testsuite.
(This used to be commit 93306f581e3fa37d1aea67e93dc83d5a6d2fcb3f)
Diffstat (limited to 'source3')
-rw-r--r--source3/python/py_spoolss_printers_conv.c38
1 files changed, 22 insertions, 16 deletions
diff --git a/source3/python/py_spoolss_printers_conv.c b/source3/python/py_spoolss_printers_conv.c
index 3e3ef95b12..f7b2f516df 100644
--- a/source3/python/py_spoolss_printers_conv.c
+++ b/source3/python/py_spoolss_printers_conv.c
@@ -217,10 +217,8 @@ BOOL py_to_PRINTER_INFO_1(PRINTER_INFO_1 *info, PyObject *dict)
PyObject *obj, *dict_copy = PyDict_Copy(dict);
BOOL result = False;
- if (!(obj = PyDict_GetItemString(dict_copy, "level")))
- goto done;
-
- if (!PyInt_Check(obj))
+ if (!(obj = PyDict_GetItemString(dict_copy, "level")) ||
+ !PyInt_Check(obj))
goto done;
PyDict_DelItemString(dict_copy, "level");
@@ -272,25 +270,25 @@ BOOL py_to_PRINTER_INFO_2(PRINTER_INFO_2 *info, PyObject *dict,
PyObject *obj, *dict_copy = PyDict_Copy(dict);
BOOL result = False;
- /* Convert security descriptor */
+ /* Convert security descriptor - may be NULL */
- if (!(obj = PyDict_GetItemString(dict_copy, "security_descriptor")))
- goto done;
+ info->secdesc = NULL;
- if (!PyDict_Check(obj))
- goto done;
+ if ((obj = PyDict_GetItemString(dict_copy, "security_descriptor"))) {
- if (!py_to_SECDESC(&info->secdesc, obj, mem_ctx))
- goto done;
+ if (!PyDict_Check(obj))
+ goto done;
- PyDict_DelItemString(dict_copy, "security_descriptor");
+ if (!py_to_SECDESC(&info->secdesc, obj, mem_ctx))
+ goto done;
- /* Convert device mode */
+ PyDict_DelItemString(dict_copy, "security_descriptor");
+ }
- if (!(obj = PyDict_GetItemString(dict_copy, "device_mode")))
- goto done;
+ /* Convert device mode */
- if (!PyDict_Check(obj))
+ if (!(obj = PyDict_GetItemString(dict_copy, "device_mode"))
+ || !PyDict_Check(obj))
goto done;
info->devmode = talloc(mem_ctx, sizeof(DEVICEMODE));
@@ -300,6 +298,14 @@ BOOL py_to_PRINTER_INFO_2(PRINTER_INFO_2 *info, PyObject *dict,
PyDict_DelItemString(dict_copy, "device_mode");
+ /* Check info level */
+
+ if (!(obj = PyDict_GetItemString(dict_copy, "level")) ||
+ !PyInt_Check(obj))
+ goto done;
+
+ PyDict_DelItemString(dict_copy, "level");
+
/* Convert remaining elements of dictionary */
if (!to_struct(info, dict_copy, py_PRINTER_INFO_2))