[PATCH] Fix to pycredentials.c py_creds_get_ntlm_response

Alexander Bokovoy ab at samba.org
Tue Apr 18 19:36:11 UTC 2017


On ke, 19 huhti 2017, Gary Lockyer via samba-technical wrote:
> The call to PyArg_ParseTupleAndKeywords in py_creds_get_ntlm_response
> was passing incorrect parameters. I've corrected that and removed the
> server_timestamp parameter as that was not being used.
> 
> Review and push appreciated.
You also need to fix documentation -- not only it now describes wrong
signature, it also describes wrong function due to original copy/paste:

        { "get_ntlm_response", (PyCFunction)py_creds_get_ntlm_response, METH_VARARGS | METH_KEYWORDS,
                "S.get_ntlm_username_domain"
                "(flags, challenge, target_info[, server_timestamp]) -> "
                "(flags, lm_response, nt_response, lm_session_key, nt_session_key)\n"
                "Obtain LM or NTLM response." },


> 
> Gary

> From da489188faf5799c410011fc9133865d414fda6c Mon Sep 17 00:00:00 2001
> From: Gary Lockyer <gary at catalyst.net.nz>
> Date: Tue, 18 Apr 2017 15:01:05 +1200
> Subject: [PATCH] auth pycredentials: incorrect PyArg_ParseTupleAndKeywords
>  call
> 
> The challenge parameter was being treated as a string rather than as a
> data blob.  This was causing intermittent seg faults. Removed the
> server_timestamp parameter as it's not currently used.
> 
> Unable to produce a test case to reliably replicate the failure.
> 
> Signed-off-by: Gary Lockyer <gary at catalyst.net.nz>
> ---
>  auth/credentials/pycredentials.c | 10 +++++++---
>  1 file changed, 7 insertions(+), 3 deletions(-)
> 
> diff --git a/auth/credentials/pycredentials.c b/auth/credentials/pycredentials.c
> index 7f03f1f..c2d793d 100644
> --- a/auth/credentials/pycredentials.c
> +++ b/auth/credentials/pycredentials.c
> @@ -90,15 +90,19 @@ static PyObject *py_creds_get_ntlm_response(PyObject *self, PyObject *args, PyOb
>  	DATA_BLOB lm_session_key = data_blob_null;
>  	DATA_BLOB nt_session_key = data_blob_null;
>  	const char *kwnames[] = { "flags", "challenge",
> -				  "target_info", "server_timestamp",
> +				  "target_info",
>  				  NULL };
>  
>  	tv_now = timeval_current();
>  	server_timestamp = timeval_to_nttime(&tv_now);
>  
> -	if (!PyArg_ParseTupleAndKeywords(args, kwargs, "is#|s#K",
> +	if (!PyArg_ParseTupleAndKeywords(args, kwargs, "is#|s#",
>  					 discard_const_p(char *, kwnames),
> -					 &flags, &challenge, &target_info.data, &target_info.length)) {
> +					 &flags,
> +					 &challenge.data,
> +					 &challenge.length,
> +					 &target_info.data,
> +					 &target_info.length)) {
>  		return NULL;
>  	}
>  
> -- 
> 2.7.4
> 




-- 
/ Alexander Bokovoy



More information about the samba-technical mailing list