Open yani opened 1 year ago
me too, same error
This may be resolved in c50d0939917c5c757578bbaca80926740a0fad84 if someone can confirm? You can download latest from git.
On https://github.com/samyk/pwnat/commit/d1007952cd6fb2eb6ead236e48b7c330fe6f29df using i686-w64-mingw32-gcc -o pwnat.exe -O3 -DWIN32 *.c -lws2_32 -Wall -Wshadow -Wpointer-arith -Wwrite-strings
from within the src/
directory, it still fails:
Same story when trying to build on https://github.com/samyk/pwnat/commit/c50d0939917c5c757578bbaca80926740a0fad84
在 d100795 上,从目录内使用,它仍然失败:
i686-w64-mingw32-gcc -o pwnat.exe -O3 -DWIN32 *.c -lws2_32 -Wall -Wshadow -Wpointer-arith -Wwrite-strings``src/
stderr
client.c: In function ‘client_send_udp_data’: client.c:312:5: warning: implicit declaration of function ‘gettimeofday’ [-Wimplicit-function-declaration] 312 | gettimeofday(&client->tcp2udp_timeout, NULL); | ^~~~~~~~~~~~ In file included from gettimeofday.c:4: gettimeofday.h:15:8: error: redefinition of ‘struct timezone’ 15 | struct timezone | ^~~~~~~~ In file included from gettimeofday.h:4: /usr/i686-w64-mingw32/include/time.h:295:8: note: originally defined here 295 | struct timezone { | ^~~~~~~~ In file included from packet.c:16: gettimeofday.h:15:8: error: redefinition of ‘struct timezone’ 15 | struct timezone | ^~~~~~~~ In file included from gettimeofday.h:4: /usr/i686-w64-mingw32/include/time.h:295:8: note: originally defined here 295 | struct timezone { | ^~~~~~~~ pwnat.c: In function ‘main’: pwnat.c:60:37: warning: passing argument 3 of ‘getopt’ discards ‘const’ qualifier from pointer target type [-Wdiscarded-qualifiers] 60 | while((ret = getopt(argc, argv, "hscv6ap")) != EOF) | ^~~~~~~~~ In file included from pwnat.c:30: xgetopt.h:23:42: note: expected ‘char *’ but argument is of type ‘const char *’ 23 | int getopt(int argc, char *argv[], char *optstring); | ~~~~~~^~~~~~~~~ socket.c: In function ‘sock_connect’: socket.c:155:50: warning: passing argument 4 of ‘setsockopt’ from incompatible pointer type [-Wincompatible-pointer-types] 155 | setsockopt(sock->fd, SOL_SOCKET, SO_REUSEADDR, &reuseaddr, sizeof(int)); | ^~~~~~~~~~ | | | int * In file included from socket.h:30, from socket.c:35: /usr/i686-w64-mingw32/include/winsock2.h:1035:88: note: expected ‘const char *’ but argument is of type ‘int *’ 1035 | WINSOCK_API_LINKAGE int WSAAPI setsockopt(SOCKET s,int level,int optname,const char *optval,int optlen); | ~~~~~~~~~~~~^~~~~~ In file included from udpclient.c:40: gettimeofday.h:15:8: error: redefinition of ‘struct timezone’ 15 | struct timezone | ^~~~~~~~ In file included from udpclient.c:26: /usr/i686-w64-mingw32/include/time.h:295:8: note: originally defined here 295 | struct timezone { | ^~~~~~~~ udpclient.c: In function ‘udpclient’: udpclient.c:146:74: error: too many arguments to function ‘WSAGetLastError’ 146 | printf("Couldn't resolve server address: '%s': %s\n", phost, WSAGetLastError(h_errno)); | ^~~~~~~~~~~~~~~ In file included from gettimeofday.h:6: /usr/i686-w64-mingw32/include/winsock2.h:1049:34: note: declared here 1049 | WINSOCK_API_LINKAGE int WSAAPI WSAGetLastError(void); | ^~~~~~~~~~~~~~~ udpclient.c:146:61: warning: format ‘%s’ expects argument of type ‘char *’, but argument 3 has type ‘int’ [-Wformat=] 146 | printf("Couldn't resolve server address: '%s': %s\n", phost, WSAGetLastError(h_errno)); | ~^ ~~~~~~~~~~~~~~~~~~~~~~~~ | | | | char * int | %d In file included from udpserver.c:32: gettimeofday.h:15:8: error: redefinition of ‘struct timezone’ 15 | struct timezone | ^~~~~~~~ In file included from gettimeofday.h:4: /usr/i686-w64-mingw32/include/time.h:295:8: note: originally defined here 295 | struct timezone { | ^~~~~~~~ udpserver.c: In function ‘udpserver’: udpserver.c:257:40: warning: pointer targets in passing argument 2 of ‘recv’ differ in signedness [-Wpointer-sign] 257 | while ((ip = recv(listen_sock, packet, 100, 0)) > 0) | ^~~~~~ | | | unsigned char * In file included from gettimeofday.h:6: /usr/i686-w64-mingw32/include/winsock2.h:1028:54: note: expected ‘char *’ but argument is of type ‘unsigned char *’ 1028 | WINSOCK_API_LINKAGE int WSAAPI recv(SOCKET s,char *buf,int len,int flags); | ~~~~~~^~~
尝试在 c50d093 上构建时也是如此
stderr
In file included from client.c:29: common.h:31:72: warning: parameter 2 (‘src’) has void type 31 | WINSOCK_API_LINKAGE const char WSAAPI inet_ntop(int af, const void src, char *dst, socklen_t size); | ~~~~~~~~~~~^~~ common.h:31:43: error: conflicting types for ‘inet_ntop’; have ‘char(int, const void, char *, socklen_t)’ {aka ‘char(int, const void, char *, int)’} 31 | WINSOCK_API_LINKAGE const char WSAAPI inet_ntop(int af, const void src, char *dst, socklen_t size); | ^~~~~~~~~ In file included from common.h:30: /usr/i686-w64-mingw32/include/ws2tcpip.h:400:35: note: previous declaration of ‘inet_ntop’ with type ‘const CHAR *(INT, const void *, CHAR *, size_t)’ {aka ‘const char *(int, const void *, char *, unsigned int)’} 400 | WINSOCK_API_LINKAGE LPCSTR WSAAPI InetNtopA(INT Family, LPCVOID pAddr, LPSTR pStringBuf, size_t StringBufSize); | ^~~~~~~~~ client.c: In function ‘client_send_udp_data’: client.c:312:5: warning: implicit declaration of function ‘gettimeofday’ [-Wimplicit-function-declaration] 312 | gettimeofday(&client->tcp2udp_timeout, NULL); | ^~~~~~~~~~~~ In file included from gettimeofday.c:4: gettimeofday.h:17:24: warning: "/*" within comment [-Wcomment] 17 | int tz_minuteswest; /* minutes W of Greenwich * | gettimeofday.h:18:24: warning: "/*" within comment [-Wcomment] 18 | int tz_dsttime; /* type of dst correction * | gettimeofday.c: In function ‘gettimeofday’: gettimeofday.c:22:15: error: ‘DELTA_EPOCH_IN_MICROSECS’ undeclared (first use in this function) 22 | tmpres -= DELTA_EPOCH_IN_MICROSECS; | ^~~~~~~~~~~~~~~~~~~~~~~~ gettimeofday.c:22:15: note: each undeclared identifier is reported only once for each function it appears in In file included from list.h:25, from list.c:24: common.h:31:72: warning: parameter 2 (‘src’) has void type 31 | WINSOCK_API_LINKAGE const char WSAAPI inet_ntop(int af, const void src, char *dst, socklen_t size); | ~~~~~~~~~~~^~~ common.h:31:43: error: conflicting types for ‘inet_ntop’; have ‘char(int, const void, char *, socklen_t)’ {aka ‘char(int, const void, char *, int)’} 31 | WINSOCK_API_LINKAGE const char WSAAPI inet_ntop(int af, const void src, char *dst, socklen_t size); | ^~~~~~~~~ In file included from common.h:30: /usr/i686-w64-mingw32/include/ws2tcpip.h:400:35: note: previous declaration of ‘inet_ntop’ with type ‘const CHAR *(INT, const void *, CHAR *, size_t)’ {aka ‘const char *(int, const void *, char *, unsigned int)’} 400 | WINSOCK_API_LINKAGE LPCSTR WSAAPI InetNtopA(INT Family, LPCVOID pAddr, LPSTR pStringBuf, size_t StringBufSize); | ^~~~~~~~~ In file included from message.c:30: common.h:31:72: warning: parameter 2 (‘src’) has void type 31 | WINSOCK_API_LINKAGE const char WSAAPI inet_ntop(int af, const void src, char *dst, socklen_t size); | ~~~~~~~~~~~^~~ common.h:31:43: error: conflicting types for ‘inet_ntop’; have ‘char(int, const void, char *, socklen_t)’ {aka ‘char(int, const void, char *, int)’} 31 | WINSOCK_API_LINKAGE const char WSAAPI inet_ntop(int af, const void src, char *dst, socklen_t size); | ^~~~~~~~~ In file included from common.h:30: /usr/i686-w64-mingw32/include/ws2tcpip.h:400:35: note: previous declaration of ‘inet_ntop’ with type ‘const CHAR *(INT, const void *, CHAR *, size_t)’ {aka ‘const char *(int, const void *, char *, unsigned int)’} 400 | WINSOCK_API_LINKAGE LPCSTR WSAAPI InetNtopA(INT Family, LPCVOID pAddr, LPSTR pStringBuf, size_t StringBufSize); | ^~~~~~~~~ In file included from packet.c:16: gettimeofday.h:17:24: warning: "/*" within comment [-Wcomment] 17 | int tz_minuteswest; /* minutes W of Greenwich * | gettimeofday.h:18:24: warning: "/*" within comment [-Wcomment] 18 | int tz_dsttime; /* type of dst correction * | In file included from packet.c:22: common.h:31:72: warning: parameter 2 (‘src’) has void type 31 | WINSOCK_API_LINKAGE const char WSAAPI inet_ntop(int af, const void src, char *dst, socklen_t size); | ~~~~~~~~~~~^~~ common.h:31:43: error: conflicting types for ‘inet_ntop’; have ‘char(int, const void, char *, socklen_t)’ {aka ‘char(int, const void, char *, int)’} 31 | WINSOCK_API_LINKAGE const char WSAAPI inet_ntop(int af, const void src, char *dst, socklen_t size); | ^~~~~~~~~ In file included from common.h:30: /usr/i686-w64-mingw32/include/ws2tcpip.h:400:35: note: previous declaration of ‘inet_ntop’ with type ‘const CHAR *(INT, const void *, CHAR *, size_t)’ {aka ‘const char *(int, const void *, char *, unsigned int)’} 400 | WINSOCK_API_LINKAGE LPCSTR WSAAPI InetNtopA(INT Family, LPCVOID pAddr, LPSTR pStringBuf, size_t StringBufSize); | ^~~~~~~~~ In file included from pwnat.c:33: common.h:31:72: warning: parameter 2 (‘src’) has void type 31 | WINSOCK_API_LINKAGE const char WSAAPI inet_ntop(int af, const void src, char *dst, socklen_t size); | ~~~~~~~~~~~^~~ common.h:31:43: error: conflicting types for ‘inet_ntop’; have ‘char(int, const void, char *, socklen_t)’ {aka ‘char(int, const void, char *, int)’} 31 | WINSOCK_API_LINKAGE const char WSAAPI inet_ntop(int af, const void src, char *dst, socklen_t size); | ^~~~~~~~~ In file included from common.h:30: /usr/i686-w64-mingw32/include/ws2tcpip.h:400:35: note: previous declaration of ‘inet_ntop’ with type ‘const CHAR *(INT, const void *, CHAR *, size_t)’ {aka ‘const char *(int, const void *, char *, unsigned int)’} 400 | WINSOCK_API_LINKAGE LPCSTR WSAAPI InetNtopA(INT Family, LPCVOID pAddr, LPSTR pStringBuf, size_t StringBufSize); | ^~~~~~~~~ pwnat.c: In function ‘main’: pwnat.c:60:37: warning: passing argument 3 of ‘getopt’ discards ‘const’ qualifier from pointer target type [-Wdiscarded-qualifiers] 60 | while((ret = getopt(argc, argv, "hscv6ap")) != EOF) | ^~~~~~~~~ In file included from pwnat.c:30: xgetopt.h:23:42: note: expected ‘char *’ but argument is of type ‘const char *’ 23 | int getopt(int argc, char *argv[], char *optstring); | ~~~~~~^~~~~~~~~ In file included from socket.h:34, from socket.c:35: common.h:31:72: warning: parameter 2 (‘src’) has void type 31 | WINSOCK_API_LINKAGE const char WSAAPI inet_ntop(int af, const void src, char *dst, socklen_t size); | ~~~~~~~~~~~^~~ common.h:31:43: error: conflicting types for ‘inet_ntop’; have ‘char(int, const void, char *, socklen_t)’ {aka ‘char(int, const void, char *, int)’} 31 | WINSOCK_API_LINKAGE const char WSAAPI inet_ntop(int af, const void src, char *dst, socklen_t size); | ^~~~~~~~~ In file included from socket.h:31: /usr/i686-w64-mingw32/include/ws2tcpip.h:400:35: note: previous declaration of ‘inet_ntop’ with type ‘const CHAR *(INT, const void *, CHAR *, size_t)’ {aka ‘const char *(int, const void *, char *, unsigned int)’} 400 | WINSOCK_API_LINKAGE LPCSTR WSAAPI InetNtopA(INT Family, LPCVOID pAddr, LPSTR pStringBuf, size_t StringBufSize); | ^~~~~~~~~ socket.c: In function ‘sock_connect’: socket.c:155:50: warning: passing argument 4 of ‘setsockopt’ from incompatible pointer type [-Wincompatible-pointer-types] 155 | setsockopt(sock->fd, SOL_SOCKET, SO_REUSEADDR, &reuseaddr, sizeof(int)); | ^~~~~~~~~~ | | | int * In file included from socket.h:30: /usr/i686-w64-mingw32/include/winsock2.h:1035:88: note: expected ‘const char *’ but argument is of type ‘int *’ 1035 | WINSOCK_API_LINKAGE int WSAAPI setsockopt(SOCKET s,int level,int optname,const char *optval,int optlen); | ~~~~~~~~~~~~^~~~~~ In file included from udpclient.c:40: gettimeofday.h:17:24: warning: "/*" within comment [-Wcomment] 17 | int tz_minuteswest; /* minutes W of Greenwich * | gettimeofday.h:18:24: warning: "/*" within comment [-Wcomment] 18 | int tz_dsttime; /* type of dst correction * | In file included from udpclient.c:43: common.h:31:72: warning: parameter 2 (‘src’) has void type 31 | WINSOCK_API_LINKAGE const char WSAAPI inet_ntop(int af, const void src, char *dst, socklen_t size); | ~~~~~~~~~~~^~~ common.h:31:43: error: conflicting types for ‘inet_ntop’; have ‘char(int, const void, char *, socklen_t)’ {aka ‘char(int, const void, char *, int)’} 31 | WINSOCK_API_LINKAGE const char WSAAPI inet_ntop(int af, const void src, char *dst, socklen_t size); | ^~~~~~~~~ In file included from common.h:30: /usr/i686-w64-mingw32/include/ws2tcpip.h:400:35: note: previous declaration of ‘inet_ntop’ with type ‘const CHAR *(INT, const void *, CHAR *, size_t)’ {aka ‘const char *(int, const void *, char *, unsigned int)’} 400 | WINSOCK_API_LINKAGE LPCSTR WSAAPI InetNtopA(INT Family, LPCVOID pAddr, LPSTR pStringBuf, size_t StringBufSize); | ^~~~~~~~~ udpclient.c: In function ‘udpclient’: udpclient.c:143:70: warning: implicit declaration of function ‘hstrerror’; did you mean ‘strerror’? [-Wimplicit-function-declaration] 143 | printf("Couldn't resolve server address: '%s': %s\n", phost, hstrerror(h_errno)); | ^~~~~~~~~ | strerror udpclient.c:143:57: warning: format ‘%s’ expects argument of type ‘char *’, but argument 3 has type ‘int’ [-Wformat=] 143 | printf("Couldn't resolve server address: '%s': %s\n", phost, hstrerror(h_errno)); | ~^ ~~~~~~~~~~~~~~~~~~ | | | | char * int | %d In file included from udpserver.c:32: gettimeofday.h:17:24: warning: "/*" within comment [-Wcomment] 17 | int tz_minuteswest; /* minutes W of Greenwich * | gettimeofday.h:18:24: warning: "/*" within comment [-Wcomment] 18 | int tz_dsttime; /* type of dst correction * | In file included from udpserver.c:35: common.h:31:72: warning: parameter 2 (‘src’) has void type 31 | WINSOCK_API_LINKAGE const char WSAAPI inet_ntop(int af, const void src, char *dst, socklen_t size); | ~~~~~~~~~~~^~~ common.h:31:43: error: conflicting types for ‘inet_ntop’; have ‘char(int, const void, char *, socklen_t)’ {aka ‘char(int, const void, char *, int)’} 31 | WINSOCK_API_LINKAGE const char WSAAPI inet_ntop(int af, const void src, char *dst, socklen_t size); | ^~~~~~~~~ In file included from common.h:30: /usr/i686-w64-mingw32/include/ws2tcpip.h:400:35: note: previous declaration of ‘inet_ntop’ with type ‘const CHAR *(INT, const void *, CHAR *, size_t)’ {aka ‘const char *(int, const void *, char *, unsigned int)’} 400 | WINSOCK_API_LINKAGE LPCSTR WSAAPI InetNtopA(INT Family, LPCVOID pAddr, LPSTR pStringBuf, size_t StringBufSize); | ^~~~~~~~~ udpserver.c: In function ‘udpserver’: udpserver.c:257:40: warning: pointer targets in passing argument 2 of ‘recv’ differ in signedness [-Wpointer-sign] 257 | while ((ip = recv(listen_sock, packet, 100, 0)) > 0) | ^~~~~~ | | | unsigned char * In file included from gettimeofday.h:6: /usr/i686-w64-mingw32/include/winsock2.h:1028:54: note: expected ‘char *’ but argument is of type ‘unsigned char *’ 1028 | WINSOCK_API_LINKAGE int WSAAPI recv(SOCKET s,char *buf,int len,int flags); | ~~~~~~^~~
The error "struct timezone" is because mingw follows the POSIX specification and defines "struct timezone". The author defines "struct timezone" because "struct timezone" is not defined under Windows. To solve this error, you just need to comment "struct timezone" in "gettimeofday.h".
The same is true for the errors about "inet_pton" and "inet_ntop", you need to comment them in the HEAER file.
The reason for this may be that these functions were not defined under previous mingw.
I had to change
cross-compile-mingw.sh
to usesrc
paths:But now I'm getting the following output: