use strtok_r instead of strtok for thread safety

use_iouring
YuQing 2023-12-23 16:19:11 +08:00
parent 3f5eed3af2
commit 7816a28c53
2 changed files with 5 additions and 4 deletions

View File

@ -1,5 +1,5 @@
Version 1.71 2023-12-01
Version 1.71 2023-12-23
* full support IPv6 by pull request #47
* replace inet_ntop to getnameinfo for IPv6

View File

@ -2833,15 +2833,16 @@ int parseAddress(char *src, char *parts[2])
{
char *ip;
char *port;
char *saveptr = NULL;
if (src[0] == '[') {
ip = strtok(src, "[]");
ip = strtok_r(src, "[]", &saveptr);
} else {
ip = strtok(src, ":");
ip = strtok_r(src, ":", &saveptr);
}
parts[0] = ip;
port = strtok(NULL, ":");
port = strtok_r(NULL, ":", &saveptr);
if (port == NULL) {
return 1;
} else {