[PATCH] wldap32: Cyrus SASL's sasl_interact_t.result should be null-terminated
Damjan Jovanovic
damjan.jov at gmail.com
Fri Feb 5 01:37:28 CST 2021
Sometimes AD authentication fails as LDAP packets have garbage
characters trailing the username. Reading its source code confirms
that Cyrus SASL often completely ignores the sasl_interact_t.len field,
and expects sasl_interact_t.result to be null-terminated.
Signed-off-by: Damjan Jovanovic <damjan.jov at gmail.com>
---
dlls/wldap32/wldap32.h | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
-------------- next part --------------
diff --git a/dlls/wldap32/wldap32.h b/dlls/wldap32/wldap32.h
index 537de67a877..3059df8603e 100644
--- a/dlls/wldap32/wldap32.h
+++ b/dlls/wldap32/wldap32.h
@@ -100,9 +100,10 @@ static inline LPWSTR strnAtoW( LPCSTR str, DWORD inlen, DWORD *outlen )
if (str)
{
DWORD len = MultiByteToWideChar( CP_ACP, 0, str, inlen, NULL, 0 );
- if ((ret = heap_alloc( len * sizeof(WCHAR) )))
+ if ((ret = heap_alloc( (len+1) * sizeof(WCHAR) )))
{
MultiByteToWideChar( CP_ACP, 0, str, inlen, ret, len );
+ ret[len] = 0;
*outlen = len;
}
}
@@ -116,9 +117,10 @@ static inline char *strnWtoU( LPCWSTR str, DWORD inlen, DWORD *outlen )
if (str)
{
DWORD len = WideCharToMultiByte( CP_UTF8, 0, str, inlen, NULL, 0, NULL, NULL );
- if ((ret = heap_alloc( len )))
+ if ((ret = heap_alloc( len + 1 )))
{
WideCharToMultiByte( CP_UTF8, 0, str, inlen, ret, len, NULL, NULL );
+ ret[len] = 0;
*outlen = len;
}
}
More information about the wine-devel
mailing list