Merge
authorchegar
Fri, 07 Mar 2008 17:18:22 +0000
changeset 89 18d94f53bd30
parent 88 b2fea49cad6b (current diff)
parent 87 bf0750ece551 (diff)
child 90 12ba8f0d1494
Merge
--- a/jdk/src/windows/native/sun/net/www/protocol/http/NTLMAuthSequence.c	Fri Mar 07 17:17:49 2008 +0000
+++ b/jdk/src/windows/native/sun/net/www/protocol/http/NTLMAuthSequence.c	Fri Mar 07 17:18:22 2008 +0000
@@ -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, &ltime
         );
 
+    /* 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;