change use of strtok to strtok_s

This commit is contained in:
Kobi Mizrachi 2020-05-18 11:35:52 +03:00 committed by akallabeth
parent f79bb517c1
commit fddda159d9
3 changed files with 10 additions and 6 deletions

View File

@ -814,6 +814,7 @@ HttpResponse* http_response_recv(rdpTls* tls, BOOL readContentLength)
size_t count = 0; size_t count = 0;
char* buffer = (char*)Stream_Buffer(response->data); char* buffer = (char*)Stream_Buffer(response->data);
char* line = (char*)Stream_Buffer(response->data); char* line = (char*)Stream_Buffer(response->data);
char* context = NULL;
while ((line = string_strnstr(line, "\r\n", payloadOffset - (line - buffer) - 2UL))) while ((line = string_strnstr(line, "\r\n", payloadOffset - (line - buffer) - 2UL)))
{ {
@ -834,12 +835,12 @@ HttpResponse* http_response_recv(rdpTls* tls, BOOL readContentLength)
buffer[payloadOffset - 1] = '\0'; buffer[payloadOffset - 1] = '\0';
buffer[payloadOffset - 2] = '\0'; buffer[payloadOffset - 2] = '\0';
count = 0; count = 0;
line = strtok(buffer, "\r\n"); line = strtok_s(buffer, "\r\n", &context);
while (line && (response->count > count)) while (line && (response->count > count))
{ {
response->lines[count] = line; response->lines[count] = line;
line = strtok(NULL, "\r\n"); line = strtok_s(NULL, "\r\n", &context);
count++; count++;
} }

View File

@ -144,6 +144,7 @@ static BOOL check_no_proxy(rdpSettings* settings, const char* no_proxy)
BOOL result = FALSE; BOOL result = FALSE;
char* current; char* current;
char* copy; char* copy;
char* context = NULL;
size_t host_len; size_t host_len;
struct sockaddr_in sa4; struct sockaddr_in sa4;
struct sockaddr_in6 sa6; struct sockaddr_in6 sa6;
@ -164,7 +165,7 @@ static BOOL check_no_proxy(rdpSettings* settings, const char* no_proxy)
if (!copy) if (!copy)
return FALSE; return FALSE;
current = strtok(copy, delimiter); current = strtok_s(copy, delimiter, &context);
while (current && !result) while (current && !result)
{ {
@ -243,7 +244,7 @@ static BOOL check_no_proxy(rdpSettings* settings, const char* no_proxy)
} }
} }
current = strtok(NULL, delimiter); current = strtok_s(NULL, delimiter, &context);
} }
free(copy); free(copy);

View File

@ -248,12 +248,14 @@ static BOOL winpr_match_unix_timezone_identifier_with_list(const char* tzid, con
{ {
char* p; char* p;
char* list_copy; char* list_copy;
char* context = NULL;
list_copy = _strdup(list); list_copy = _strdup(list);
if (!list_copy) if (!list_copy)
return FALSE; return FALSE;
p = strtok(list_copy, " "); p = strtok_s(list_copy, " ", &context);
while (p != NULL) while (p != NULL)
{ {
@ -263,7 +265,7 @@ static BOOL winpr_match_unix_timezone_identifier_with_list(const char* tzid, con
return TRUE; return TRUE;
} }
p = strtok(NULL, " "); p = strtok_s(NULL, " ", &context);
} }
free(list_copy); free(list_copy);