The Windows Sockets documentation recommends using WSAGetLastError()
instead of gai_strerror(), because the latter is not thread safe:
https://docs.microsoft.com/en-us/windows/win32/winsock/error-codes-errno-h-errno-and-wsagetlasterror-2
Properly decode the output using openconnect__win32_strerror().
Signed-off-by: Dimitri Papadopoulos <3350651-DimitriPapadopoulos@users.noreply.gitlab.com>
err = getaddrinfo(hostname, port, &hints, &result);
if (err) {
+#ifdef _WIN32
+ char *errstr = openconnect__win32_strerror(WSAGetLastError());
+#else
+ const char *errstr = gai_strerror(err);
+#endif
vpn_progress(vpninfo, PRG_ERR,
_("getaddrinfo failed for host '%s': %s\n"),
- hostname, gai_strerror(err));
+ hostname, errstr);
+#ifdef _WIN32
+ free(errstr);
+#endif
if (hints.ai_flags & AI_NUMERICHOST)
free(hostname);
ssl_sock = -EINVAL;