From d75fc27fa1b68762317999d65a232284abf72ef6 Mon Sep 17 00:00:00 2001 From: Tim Potter Date: Mon, 2 Sep 2002 07:42:39 +0000 Subject: Fix transposed args in open_pipe_creds() function. (This used to be commit 63e59b0b737a1cd4ccc588b27e86be8262296052) --- source3/python/py_common.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source3/python/py_common.c') diff --git a/source3/python/py_common.c b/source3/python/py_common.c index a65206e022..6247bf6371 100644 --- a/source3/python/py_common.c +++ b/source3/python/py_common.c @@ -211,7 +211,7 @@ struct cli_state *open_pipe_creds(char *server, PyObject *creds, /* Extract credentials from the python dictionary */ - if (!py_parse_creds(creds, &username, &password, &domain, errstr)) + if (!py_parse_creds(creds, &username, &domain, &password, errstr)) return NULL; /* Now try to connect */ -- cgit From bffdffcbb10db9a510c8713158cb3e4044b23c2c Mon Sep 17 00:00:00 2001 From: Tim Potter Date: Mon, 9 Sep 2002 01:06:20 +0000 Subject: Check no extra fields are present when parsing credentials. (This used to be commit fff081d3440373071d8859b7a7d71cf6489126a4) --- source3/python/py_common.c | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) (limited to 'source3/python/py_common.c') diff --git a/source3/python/py_common.c b/source3/python/py_common.c index 6247bf6371..e21858e072 100644 --- a/source3/python/py_common.c +++ b/source3/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); -- cgit