8036088: Replace strtok() with its safe equivalent strtok_s() in DefaultProxySelector.c

Reviewed-by: chegar
This commit is contained in:
Ivan Gerasimov 2014-03-13 07:24:12 +04:00
parent 769affa9c4
commit 91eeeafb13

View File

@ -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);