diff options
author | Tim Potter <tpot@samba.org> | 2002-09-09 01:06:20 +0000 |
---|---|---|
committer | Tim Potter <tpot@samba.org> | 2002-09-09 01:06:20 +0000 |
commit | fff081d3440373071d8859b7a7d71cf6489126a4 (patch) | |
tree | b08d373b191a7e5ec36b13f6b704d4abfb86e6fc /source/python | |
parent | 31feae9e8f0c9831284cfa85f9b771113549ed2f (diff) | |
download | samba-fff081d3440373071d8859b7a7d71cf6489126a4.tar.gz samba-fff081d3440373071d8859b7a7d71cf6489126a4.tar.xz samba-fff081d3440373071d8859b7a7d71cf6489126a4.zip |
Check no extra fields are present when parsing credentials.
Diffstat (limited to 'source/python')
-rw-r--r-- | source/python/py_common.c | 19 |
1 files changed, 17 insertions, 2 deletions
diff --git a/source/python/py_common.c b/source/python/py_common.c index 6247bf63717..e21858e0722 100644 --- a/source/python/py_common.c +++ b/source/python/py_common.c @@ -144,6 +144,8 @@ BOOL py_parse_creds(PyObject *creds, char **username, char **domain, if (creds && PyDict_Size(creds) > 0) { PyObject *username_obj, *password_obj, *domain_obj; + PyObject *key, *value; + int i; /* Check for presence of required fields */ @@ -166,8 +168,6 @@ BOOL py_parse_creds(PyObject *creds, char **username, char **domain, return False; } - /* Look for any other fields */ - /* Check type of required fields */ if (!PyString_Check(username_obj)) { @@ -185,6 +185,21 @@ BOOL py_parse_creds(PyObject *creds, char **username, char **domain, return False; } + /* Look for any extra fields */ + + i = 0; + + while (PyDict_Next(creds, &i, &key, &value)) { + if (strcmp(PyString_AsString(key), "domain") != 0 && + strcmp(PyString_AsString(key), "username") != 0 && + strcmp(PyString_AsString(key), "password") != 0) { + asprintf(errstr, + "creds contain extra field '%s'", + PyString_AsString(key)); + return False; + } + } + /* Assign values */ *username = PyString_AsString(username_obj); |