mongodb / winkerberos

A native Kerberos client implementation for Python on Windows
Apache License 2.0
54 stars 15 forks source link

Raise ValueError when appropriate if input exceeds ULONG_MAX #9

Closed behackett closed 8 years ago

behackett commented 8 years ago

Microsoft APIs like CryptStringToBinary and structs like SecBuffer and SEC_WINNT_AUTH_IDENTITY expect string length as ULONG. Python string length is defined as Py_ssize_t (ssize_t on platforms that define it). We should raise ValueError if the length of input strings exceeds ULONG_MAX. Currently these strings are truncated on 64 bit systems. Raising an explicit exception will make debugging much easier than authentication failing.

behackett commented 8 years ago

For reference:

https://msdn.microsoft.com/en-us/library/296az74e.aspx https://msdn.microsoft.com/en-us/library/windows/desktop/aa383751(v=vs.85).aspx