diff options
| author | rpatters1 <rpatters1@users.noreply.github.com> | 2022-07-27 01:51:35 -0500 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2022-07-27 09:51:35 +0300 |
| commit | 5a7e3f08886ef2893148c1342fb6021291cf1307 (patch) | |
| tree | 923de9ce9c045e8f2f55a5acb6b1551911521068 /src | |
| parent | d1ad8160cba9e504c9d17665492044a93efdc3ab (diff) | |
| download | luasocket-5a7e3f08886ef2893148c1342fb6021291cf1307.tar.gz luasocket-5a7e3f08886ef2893148c1342fb6021291cf1307.tar.bz2 luasocket-5a7e3f08886ef2893148c1342fb6021291cf1307.zip | |
fix(build): Use gai_strerrorA not gai_strerror on Windows
* Explicitly call gai_strerrorA (for Windows builds), so that the code work correctly in 32bit or 64bit builds.
* Implement GAI_STRERROR macro to deal with Windows vs. Non-Windows compiles for 64-bit.
* make usocket.c consistent with other modules that call macro GAI_STRERROR
* Use different name not just different case for macro wrapping function
Co-authored-by: Caleb Maclennan <caleb@alerque.com>
Diffstat (limited to 'src')
| -rwxr-xr-x[-rw-r--r--] | src/inet.c | 4 | ||||
| -rwxr-xr-x[-rw-r--r--] | src/socket.h | 2 | ||||
| -rwxr-xr-x[-rw-r--r--] | src/udp.c | 4 | ||||
| -rw-r--r-- | src/usocket.c | 2 | ||||
| -rwxr-xr-x | src/wsocket.c | 2 |
5 files changed, 8 insertions, 6 deletions
diff --git a/src/inet.c b/src/inet.c index ec73fea..138c9ab 100644..100755 --- a/src/inet.c +++ b/src/inet.c | |||
| @@ -253,7 +253,7 @@ int inet_meth_getpeername(lua_State *L, p_socket ps, int family) | |||
| 253 | port, sizeof(port), NI_NUMERICHOST | NI_NUMERICSERV); | 253 | port, sizeof(port), NI_NUMERICHOST | NI_NUMERICSERV); |
| 254 | if (err) { | 254 | if (err) { |
| 255 | lua_pushnil(L); | 255 | lua_pushnil(L); |
| 256 | lua_pushstring(L, gai_strerror(err)); | 256 | lua_pushstring(L, LUA_GAI_STRERROR(err)); |
| 257 | return 2; | 257 | return 2; |
| 258 | } | 258 | } |
| 259 | lua_pushstring(L, name); | 259 | lua_pushstring(L, name); |
| @@ -286,7 +286,7 @@ int inet_meth_getsockname(lua_State *L, p_socket ps, int family) | |||
| 286 | name, INET6_ADDRSTRLEN, port, 6, NI_NUMERICHOST | NI_NUMERICSERV); | 286 | name, INET6_ADDRSTRLEN, port, 6, NI_NUMERICHOST | NI_NUMERICSERV); |
| 287 | if (err) { | 287 | if (err) { |
| 288 | lua_pushnil(L); | 288 | lua_pushnil(L); |
| 289 | lua_pushstring(L, gai_strerror(err)); | 289 | lua_pushstring(L, LUA_GAI_STRERROR(err)); |
| 290 | return 2; | 290 | return 2; |
| 291 | } | 291 | } |
| 292 | lua_pushstring(L, name); | 292 | lua_pushstring(L, name); |
diff --git a/src/socket.h b/src/socket.h index e541f27..2555bab 100644..100755 --- a/src/socket.h +++ b/src/socket.h | |||
| @@ -16,8 +16,10 @@ | |||
| 16 | \*=========================================================================*/ | 16 | \*=========================================================================*/ |
| 17 | #ifdef _WIN32 | 17 | #ifdef _WIN32 |
| 18 | #include "wsocket.h" | 18 | #include "wsocket.h" |
| 19 | #define LUA_GAI_STRERROR gai_strerrorA | ||
| 19 | #else | 20 | #else |
| 20 | #include "usocket.h" | 21 | #include "usocket.h" |
| 22 | #define LUA_GAI_STRERROR gai_strerror | ||
| 21 | #endif | 23 | #endif |
| 22 | 24 | ||
| 23 | /*=========================================================================*\ | 25 | /*=========================================================================*\ |
| @@ -191,7 +191,7 @@ static int meth_sendto(lua_State *L) { | |||
| 191 | err = getaddrinfo(ip, port, &aihint, &ai); | 191 | err = getaddrinfo(ip, port, &aihint, &ai); |
| 192 | if (err) { | 192 | if (err) { |
| 193 | lua_pushnil(L); | 193 | lua_pushnil(L); |
| 194 | lua_pushstring(L, gai_strerror(err)); | 194 | lua_pushstring(L, LUA_GAI_STRERROR(err)); |
| 195 | return 2; | 195 | return 2; |
| 196 | } | 196 | } |
| 197 | 197 | ||
| @@ -290,7 +290,7 @@ static int meth_receivefrom(lua_State *L) { | |||
| 290 | INET6_ADDRSTRLEN, portstr, 6, NI_NUMERICHOST | NI_NUMERICSERV); | 290 | INET6_ADDRSTRLEN, portstr, 6, NI_NUMERICHOST | NI_NUMERICSERV); |
| 291 | if (err) { | 291 | if (err) { |
| 292 | lua_pushnil(L); | 292 | lua_pushnil(L); |
| 293 | lua_pushstring(L, gai_strerror(err)); | 293 | lua_pushstring(L, LUA_GAI_STRERROR(err)); |
| 294 | if (wanted > sizeof(buf)) free(dgram); | 294 | if (wanted > sizeof(buf)) free(dgram); |
| 295 | return 2; | 295 | return 2; |
| 296 | } | 296 | } |
diff --git a/src/usocket.c b/src/usocket.c index acfe186..69635da 100644 --- a/src/usocket.c +++ b/src/usocket.c | |||
| @@ -449,6 +449,6 @@ const char *socket_gaistrerror(int err) { | |||
| 449 | case EAI_SERVICE: return PIE_SERVICE; | 449 | case EAI_SERVICE: return PIE_SERVICE; |
| 450 | case EAI_SOCKTYPE: return PIE_SOCKTYPE; | 450 | case EAI_SOCKTYPE: return PIE_SOCKTYPE; |
| 451 | case EAI_SYSTEM: return strerror(errno); | 451 | case EAI_SYSTEM: return strerror(errno); |
| 452 | default: return gai_strerror(err); | 452 | default: return LUA_GAI_STRERROR(err); |
| 453 | } | 453 | } |
| 454 | } | 454 | } |
diff --git a/src/wsocket.c b/src/wsocket.c index 7cd4115..6cb1e41 100755 --- a/src/wsocket.c +++ b/src/wsocket.c | |||
| @@ -429,6 +429,6 @@ const char *socket_gaistrerror(int err) { | |||
| 429 | #ifdef EAI_SYSTEM | 429 | #ifdef EAI_SYSTEM |
| 430 | case EAI_SYSTEM: return strerror(errno); | 430 | case EAI_SYSTEM: return strerror(errno); |
| 431 | #endif | 431 | #endif |
| 432 | default: return gai_strerror(err); | 432 | default: return LUA_GAI_STRERROR(err); |
| 433 | } | 433 | } |
| 434 | } | 434 | } |
