better workaround for alpine

This commit is contained in:
John
2024-10-27 10:13:57 +01:00
parent 21f2d1def7
commit d2d0f5a9b9
+6 -1
View File
@@ -69,16 +69,21 @@ int tcpConnToUdpOptions, int tcpKeepAliveInterval, struct in_addr* storeIntf) {
struct in_addr intf; struct in_addr intf;
intf.s_addr = INADDR_ANY; intf.s_addr = INADDR_ANY;
if (pos) { if (pos) {
char* str = reinterpret_cast<char*>(strdupa(server)); // (char*) needed for wrong return type on e.g. Alpine size_t len = strlen(server)+1; // workaround for e.g. Alpine with wrong return type on strdupa()
char* str = reinterpret_cast<char*>(malloc(len));
strcpy(str, server);
char* ifa = strchr(str, '@'); char* ifa = strchr(str, '@');
ifa[0] = 0; ifa[0] = 0;
ifa++; ifa++;
if (!str[0] || !parseIp(str, &address->sin_addr)) { if (!str[0] || !parseIp(str, &address->sin_addr)) {
free(str);
return -1; return -1;
} }
if (!parseIp(ifa, &intf)) { if (!parseIp(ifa, &intf)) {
free(str);
return -1; return -1;
} }
free(str);
} else if (!parseIp(server, &address->sin_addr)) { } else if (!parseIp(server, &address->sin_addr)) {
return -1; return -1;
} }