From 91eeeafb130bfd1c90b5245c537cfd996381c966 Mon Sep 17 00:00:00 2001 From: Ivan Gerasimov Date: Thu, 13 Mar 2014 07:24:12 +0400 Subject: [PATCH] 8036088: Replace strtok() with its safe equivalent strtok_s() in DefaultProxySelector.c Reviewed-by: chegar --- jdk/src/windows/native/sun/net/spi/DefaultProxySelector.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/jdk/src/windows/native/sun/net/spi/DefaultProxySelector.c b/jdk/src/windows/native/sun/net/spi/DefaultProxySelector.c index e6727a78084..20e54df0580 100644 --- a/jdk/src/windows/native/sun/net/spi/DefaultProxySelector.c +++ b/jdk/src/windows/native/sun/net/spi/DefaultProxySelector.c @@ -127,12 +127,13 @@ Java_sun_net_spi_DefaultProxySelector_getSystemProxy(JNIEnv *env, 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 @@ Java_sun_net_spi_DefaultProxySelector_getSystemProxy(JNIEnv *env, * 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 @@ Java_sun_net_spi_DefaultProxySelector_getSystemProxy(JNIEnv *env, (*env)->ReleaseStringUTFChars(env, host, urlhost); goto noproxy; } - s = strtok(NULL, "; "); + s = strtok_s(NULL, "; ", &ctx); } if (isCopy == JNI_TRUE) (*env)->ReleaseStringUTFChars(env, host, urlhost);