Quantcast

[PATCH] Fix to pycredentials.c py_creds_get_ntlm_response

classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

[PATCH] Fix to pycredentials.c py_creds_get_ntlm_response

Samba - samba-technical mailing list
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.

Gary

0001-auth-pycredentials-incorrect-PyArg_ParseTupleAndKeyw.patch (1K) Download Attachment
signature.asc (484 bytes) Download Attachment
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: [PATCH] Fix to pycredentials.c py_creds_get_ntlm_response

Samba - samba-technical mailing list
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 <[hidden email]>
> 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 <[hidden email]>
> ---
>  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

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: [PATCH] Fix to pycredentials.c py_creds_get_ntlm_response

Samba - samba-technical mailing list
Updated patch attached.

On 19/04/17 07:36, Alexander Bokovoy via samba-technical wrote:

> 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 <[hidden email]>
>> 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 <[hidden email]>
>> ---
>>  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
>>
>
>
>
>

0001-auth-pycredentials-incorrect-PyArg_ParseTupleAndKeyw.patch (2K) Download Attachment
signature.asc (484 bytes) Download Attachment
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: [PATCH] Fix to pycredentials.c py_creds_get_ntlm_response

Samba - samba-technical mailing list
On Wed, 2017-04-19 at 08:05 +1200, Gary Lockyer via samba-technical
wrote:
> Updated patch attached.

Reviewed-by: Andrew Bartlett <[hidden email]>

Thanks,

Andrew Bartlett
--
Andrew Bartlett                       http://samba.org/~abartlet/
Authentication Developer, Samba Team  http://samba.org
Samba Developer, Catalyst IT          http://catalyst.net.nz/services/samba


Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: [PATCH] Fix to pycredentials.c py_creds_get_ntlm_response

Samba - samba-technical mailing list
On pe, 21 huhti 2017, Andrew Bartlett via samba-technical wrote:
> On Wed, 2017-04-19 at 08:05 +1200, Gary Lockyer via samba-technical
> wrote:
> > Updated patch attached.
>
> Reviewed-by: Andrew Bartlett <[hidden email]>
Thanks. Please push with yours' and mine RB+.


--
/ Alexander Bokovoy

Loading...