8036088: Replace strtok() with its safe equivalent strtok_s() in DefaultProxySelector.c
authorigerasim
Thu, 13 Mar 2014 07:24:12 +0400
changeset 23343 bc82981ff581
parent 23342 d7a41da68b85
child 23344 70f819173479
8036088: Replace strtok() with its safe equivalent strtok_s() in DefaultProxySelector.c Reviewed-by: chegar
jdk/src/windows/native/sun/net/spi/DefaultProxySelector.c
--- a/jdk/src/windows/native/sun/net/spi/DefaultProxySelector.c	Wed Mar 12 20:18:47 2014 +0100
+++ b/jdk/src/windows/native/sun/net/spi/DefaultProxySelector.c	Thu Mar 13 07:24:12 2014 +0400
@@ -127,12 +127,13 @@
   char regserver[MAX_STR_LEN];
   char override[MAX_STR_LEN];
   char *s, *s2;
+  char *ctx = NULL;
   int pport = 0;
   int defport = 0;
   char *phost;
 
   /**
-   * Let's opem the Registry entry. We'll check a few values in it:
+   * Let's open the Registry entry. We'll check a few values in it:
    *
    * - ProxyEnable: 0 means no proxy, 1 means use the proxy
    * - ProxyServer: a string that can take 2 forms:
@@ -177,7 +178,7 @@
            * The semicolons (;) separated entries have to be matched with the
            * the beginning of the hostname.
            */
-          s = strtok(override, "; ");
+          s = strtok_s(override, "; ", &ctx);
           urlhost = (*env)->GetStringUTFChars(env, host, &isCopy);
           if (urlhost == NULL) {
             if (!(*env)->ExceptionCheck(env))
@@ -194,7 +195,7 @@
                 (*env)->ReleaseStringUTFChars(env, host, urlhost);
               goto noproxy;
             }
-            s = strtok(NULL, "; ");
+            s = strtok_s(NULL, "; ", &ctx);
           }
           if (isCopy == JNI_TRUE)
             (*env)->ReleaseStringUTFChars(env, host, urlhost);