Merge of argument check fixes from HEAD.
authorTim Potter <tpot@samba.org>
Fri, 29 Nov 2002 01:11:08 +0000 (01:11 +0000)
committerTim Potter <tpot@samba.org>
Fri, 29 Nov 2002 01:11:08 +0000 (01:11 +0000)
(This used to be commit 5ea2edaadd87c24f63991678183c5d01225eabf7)

source3/python/py_spoolss_printers_conv.c

index 3e3ef95b125d592fcd81a677a184591b307f086a..f7b2f516df5f2e92750f1490ea11738ea4819002 100644 (file)
@@ -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))