6628661: NTLM-authentication doesn't work with non-ASCII letters
Summary: Use JNU_GetStringPlatformChars to convert jstrings to the locale specific native C strings
Reviewed-by: michaelm
--- a/jdk/src/windows/native/sun/net/www/protocol/http/NTLMAuthSequence.c Fri Mar 07 13:00:44 2008 +0000
+++ b/jdk/src/windows/native/sun/net/www/protocol/http/NTLMAuthSequence.c Fri Mar 07 07:25:17 2008 -0800
@@ -36,6 +36,8 @@
#include <tchar.h>
#include <fcntl.h>
+#include "jni_util.h"
+
#define SECURITY_WIN32
#include "sspi.h"
#include "issperr.h"
@@ -117,22 +119,36 @@
{
SEC_WINNT_AUTH_IDENTITY AuthId;
SEC_WINNT_AUTH_IDENTITY * pAuthId;
- CHAR *pUser = 0;
- CHAR *pDomain = 0;
- CHAR *pPassword = 0;
+ const CHAR *pUser = 0;
+ const CHAR *pDomain = 0;
+ const CHAR *pPassword = 0;
CredHandle *pCred;
TimeStamp ltime;
jboolean isCopy;
SECURITY_STATUS ss;
if (user != 0) {
- pUser = (CHAR *)(*env)->GetStringUTFChars(env, user, &isCopy);
+ pUser = JNU_GetStringPlatformChars(env, user, &isCopy);
+ if (pUser == NULL)
+ return 0; // pending Exception
}
if (domain != 0) {
- pDomain = (CHAR *)(*env)->GetStringUTFChars(env, domain, &isCopy);
+ pDomain = JNU_GetStringPlatformChars(env, domain, &isCopy);
+ if (pDomain == NULL) {
+ if (pUser != NULL)
+ JNU_ReleaseStringPlatformChars(env, user, pUser);
+ return 0; // pending Exception
+ }
}
if (password != 0) {
- pPassword = (CHAR *)(*env)->GetStringUTFChars(env, password, &isCopy);
+ pPassword = JNU_GetStringPlatformChars(env, password, &isCopy);
+ if (pPassword == NULL) {
+ if(pUser != NULL)
+ JNU_ReleaseStringPlatformChars(env, user, pUser);
+ if(pDomain != NULL)
+ JNU_ReleaseStringPlatformChars(env, domain, pDomain);
+ return 0; // pending Exception
+ }
}
pCred = (CredHandle *)malloc(sizeof (CredHandle));
@@ -167,6 +183,14 @@
pCred, <ime
);
+ /* Release resources held by JNU_GetStringPlatformChars */
+ if (pUser != NULL)
+ JNU_ReleaseStringPlatformChars(env, user, pUser);
+ if (pPassword != NULL)
+ JNU_ReleaseStringPlatformChars(env, password, pPassword);
+ if (pDomain != NULL)
+ JNU_ReleaseStringPlatformChars(env, domain, pDomain);
+
if (ss == 0) {
return (jlong) pCred;
} else {
@@ -181,7 +205,6 @@
VOID *pInput = 0;
DWORD inputLen;
CHAR buffOut[512];
- DWORD pcbBuffOut;
jboolean isCopy;
SECURITY_STATUS ss;
SecBufferDesc OutBuffDesc;