aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRon Yorston <rmy@pobox.com>2020-06-03 15:08:16 +0100
committerRon Yorston <rmy@pobox.com>2020-06-03 15:50:04 +0100
commit214caad089b620f2b210c0948b1526d64932a256 (patch)
tree8811139935cfa12bfbfafd9b40c0e22c197bd07b
parent27c718aa1a4674587925adb543362cb8e60814c4 (diff)
downloadbusybox-w32-214caad089b620f2b210c0948b1526d64932a256.tar.gz
busybox-w32-214caad089b620f2b210c0948b1526d64932a256.tar.bz2
busybox-w32-214caad089b620f2b210c0948b1526d64932a256.zip
win32: fix networking problems
The subprocess that handles incoming connections for httpd didn't work. It has an accepted connection on stdin and calls getpeername() to obtain its details, but getpeername() didn't initialise networking. ssl_client only seems to deal with file descriptors. Expose init_winsock() again and call it from ssl_client.
-rw-r--r--include/mingw.h1
-rw-r--r--networking/ssl_client.c1
-rw-r--r--win32/net.c6
3 files changed, 6 insertions, 2 deletions
diff --git a/include/mingw.h b/include/mingw.h
index fa8f705b0..e2d6299b9 100644
--- a/include/mingw.h
+++ b/include/mingw.h
@@ -509,6 +509,7 @@ void qsort_string_vector_case(char **sv, unsigned count) FAST_FUNC;
509 */ 509 */
510 510
511const char *get_busybox_exec_path(void); 511const char *get_busybox_exec_path(void);
512void init_winsock(void);
512void init_codepage(void); 513void init_codepage(void);
513 514
514int has_bat_suffix(const char *p); 515int has_bat_suffix(const char *p);
diff --git a/networking/ssl_client.c b/networking/ssl_client.c
index cd0ee5722..27575a2bf 100644
--- a/networking/ssl_client.c
+++ b/networking/ssl_client.c
@@ -64,6 +64,7 @@ int ssl_client_main(int argc UNUSED_PARAM, char **argv)
64 else { 64 else {
65 if (!hstr || sscanf(hstr, "%p", &h) != 1) 65 if (!hstr || sscanf(hstr, "%p", &h) != 1)
66 bb_error_msg_and_die("invalid handle"); 66 bb_error_msg_and_die("invalid handle");
67 init_winsock();
67 tls->ifd = tls->ofd = _open_osfhandle((intptr_t)h, _O_RDWR|_O_BINARY); 68 tls->ifd = tls->ofd = _open_osfhandle((intptr_t)h, _O_RDWR|_O_BINARY);
68 } 69 }
69#endif 70#endif
diff --git a/win32/net.c b/win32/net.c
index 880b807b7..33dc837fa 100644
--- a/win32/net.c
+++ b/win32/net.c
@@ -10,7 +10,7 @@ int inet_aton(const char *cp, struct in_addr *inp)
10 return 1; 10 return 1;
11} 11}
12 12
13static void init_winsock(void) 13void init_winsock(void)
14{ 14{
15 WSADATA wsa; 15 WSADATA wsa;
16 static int initialized = 0; 16 static int initialized = 0;
@@ -134,8 +134,10 @@ int mingw_accept(int sockfd1, struct sockaddr *sa, socklen_t *sz)
134#undef getpeername 134#undef getpeername
135int mingw_getpeername(int fd, struct sockaddr *sa, socklen_t *sz) 135int mingw_getpeername(int fd, struct sockaddr *sa, socklen_t *sz)
136{ 136{
137 SOCKET sock = (SOCKET)_get_osfhandle(fd); 137 SOCKET sock;
138 138
139 init_winsock();
140 sock = (SOCKET)_get_osfhandle(fd);
139 if (sock == INVALID_SOCKET) { 141 if (sock == INVALID_SOCKET) {
140 errno = EBADF; 142 errno = EBADF;
141 return -1; 143 return -1;