1
0
mirror of https://github.com/samba-team/samba.git synced 2025-07-28 11:42:03 +03:00

Stricter validation in python->C conversion functions.

(This used to be commit 672c07e243)
This commit is contained in:
Tim Potter
2002-10-21 04:16:12 +00:00
parent 7f62309268
commit 69e2a9d7fa

View File

@ -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, "level");
PyDict_DelItemString(dict_copy, "name");
if (!to_struct(form, dict_copy, py_FORM)) {
Py_DECREF(dict_copy);
return False;
}
if (!(obj = PyDict_GetItemString(dict_copy, "level")) ||
!PyInt_Check(obj))
goto done;
PyDict_DelItemString(dict_copy, "level");
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;
}