mirror of
https://github.com/SoftEtherVPN/SoftEtherVPN.git
synced 2025-04-03 18:00:08 +03:00
Use strtok_r for strtok
This commit is contained in:
parent
3baf4674e7
commit
97e0788c61
@ -2384,6 +2384,9 @@ TOKEN_LIST *ParseToken(char *src, char *separator)
|
|||||||
char *str1, *str2;
|
char *str1, *str2;
|
||||||
UINT len;
|
UINT len;
|
||||||
UINT num;
|
UINT num;
|
||||||
|
|
||||||
|
char *strtok_save;
|
||||||
|
|
||||||
if (src == NULL)
|
if (src == NULL)
|
||||||
{
|
{
|
||||||
ret = ZeroMalloc(sizeof(TOKEN_LIST));
|
ret = ZeroMalloc(sizeof(TOKEN_LIST));
|
||||||
@ -2402,24 +2405,40 @@ TOKEN_LIST *ParseToken(char *src, char *separator)
|
|||||||
|
|
||||||
Lock(token_lock);
|
Lock(token_lock);
|
||||||
{
|
{
|
||||||
tmp = strtok(str1, separator);
|
#if (defined _MSC_VER)
|
||||||
|
tmp = strtok_s(str1, separator, &strtok_save);
|
||||||
|
#else
|
||||||
|
tmp = strtok_r(str1, separator, &strtok_save);
|
||||||
|
#endif // (defined _MSC_VER)
|
||||||
num = 0;
|
num = 0;
|
||||||
while (tmp != NULL)
|
while (tmp != NULL)
|
||||||
{
|
{
|
||||||
num++;
|
num++;
|
||||||
tmp = strtok(NULL, separator);
|
#if (defined _MSC_VER)
|
||||||
|
tmp = strtok_s(NULL, separator, &strtok_save);
|
||||||
|
#else
|
||||||
|
tmp = strtok_r(NULL, separator, &strtok_save);
|
||||||
|
#endif // (defined _MSC_VER)
|
||||||
}
|
}
|
||||||
ret = Malloc(sizeof(TOKEN_LIST));
|
ret = Malloc(sizeof(TOKEN_LIST));
|
||||||
ret->NumTokens = num;
|
ret->NumTokens = num;
|
||||||
ret->Token = (char **)Malloc(sizeof(char *) * num);
|
ret->Token = (char **)Malloc(sizeof(char *) * num);
|
||||||
num = 0;
|
num = 0;
|
||||||
tmp = strtok(str2, separator);
|
#if (defined _MSC_VER)
|
||||||
|
tmp = strtok_s(str2, separator, &strtok_save);
|
||||||
|
#else
|
||||||
|
tmp = strtok_r(str2, separator, &strtok_save);
|
||||||
|
#endif // (defined _MSC_VER)
|
||||||
while (tmp != NULL)
|
while (tmp != NULL)
|
||||||
{
|
{
|
||||||
ret->Token[num] = (char *)Malloc(StrLen(tmp) + 1);
|
ret->Token[num] = (char *)Malloc(StrLen(tmp) + 1);
|
||||||
StrCpy(ret->Token[num], 0, tmp);
|
StrCpy(ret->Token[num], 0, tmp);
|
||||||
num++;
|
num++;
|
||||||
tmp = strtok(NULL, separator);
|
#if (defined _MSC_VER)
|
||||||
|
tmp = strtok_s(NULL, separator, &strtok_save);
|
||||||
|
#else
|
||||||
|
tmp = strtok_r(NULL, separator, &strtok_save);
|
||||||
|
#endif // (defined _MSC_VER)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Unlock(token_lock);
|
Unlock(token_lock);
|
||||||
|
@ -465,6 +465,7 @@ UINT VwGetBuildFromVpnInstallInf(char *buf)
|
|||||||
char tmp[MAX_SIZE];
|
char tmp[MAX_SIZE];
|
||||||
UINT wp;
|
UINT wp;
|
||||||
char seps[] = " \t";
|
char seps[] = " \t";
|
||||||
|
char *strtok_save;
|
||||||
|
|
||||||
len = lstrlen(buf);
|
len = lstrlen(buf);
|
||||||
|
|
||||||
@ -480,10 +481,18 @@ UINT VwGetBuildFromVpnInstallInf(char *buf)
|
|||||||
|
|
||||||
if (lstrlen(tmp) >= 1)
|
if (lstrlen(tmp) >= 1)
|
||||||
{
|
{
|
||||||
char *token = strtok(tmp, seps);
|
#if (defined _MSC_VER)
|
||||||
|
char *token = strtok_s(tmp, seps, &strtok_save);
|
||||||
|
#else
|
||||||
|
char *token = strtok_r(tmp, seps, &strtok_save);
|
||||||
|
#endif // (defined _MSC_VER)
|
||||||
if (token != NULL && lstrcmpi(token, VPNINSTALL_INF_BUILDTAG) == 0)
|
if (token != NULL && lstrcmpi(token, VPNINSTALL_INF_BUILDTAG) == 0)
|
||||||
{
|
{
|
||||||
token = strtok(NULL, seps);
|
#if (defined _MSC_VER)
|
||||||
|
token = strtok_s(NULL, seps, &strtok_save);
|
||||||
|
#else
|
||||||
|
token = strtok_r(NULL, seps, &strtok_save);
|
||||||
|
#endif // (defined _MSC_VER)
|
||||||
if (token != NULL)
|
if (token != NULL)
|
||||||
{
|
{
|
||||||
return (UINT)strtod(token, NULL);
|
return (UINT)strtod(token, NULL);
|
||||||
|
Loading…
Reference in New Issue
Block a user