[PATCH] Fix to pycredentials.c py_creds_get_ntlm_response
Gary Lockyer
gary at catalyst.net.nz
Tue Apr 18 20:05:45 UTC 2017
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 <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
>>
>
>
>
>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0001-auth-pycredentials-incorrect-PyArg_ParseTupleAndKeyw.patch
Type: text/x-patch
Size: 2294 bytes
Desc: not available
URL: <http://lists.samba.org/pipermail/samba-technical/attachments/20170419/62dbd4da/0001-auth-pycredentials-incorrect-PyArg_ParseTupleAndKeyw.bin>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 473 bytes
Desc: OpenPGP digital signature
URL: <http://lists.samba.org/pipermail/samba-technical/attachments/20170419/62dbd4da/signature.sig>
More information about the samba-technical
mailing list