diff options
author | jsing <> | 2014-04-15 17:25:41 +0000 |
---|---|---|
committer | jsing <> | 2014-04-15 17:25:41 +0000 |
commit | 0cfe49dc6db41fd2d4f960b618ed41b11ffffc6a (patch) | |
tree | c99aff5cf18e944ed170f9de7bd1679f2e67cab7 /src | |
parent | efda9114d24acfc8cde043a206766226c8423d7a (diff) | |
download | openbsd-0cfe49dc6db41fd2d4f960b618ed41b11ffffc6a.tar.gz openbsd-0cfe49dc6db41fd2d4f960b618ed41b11ffffc6a.tar.bz2 openbsd-0cfe49dc6db41fd2d4f960b618ed41b11ffffc6a.zip |
Toss a `unifdef -U OPENSSL_SYS_WINDOWS' bomb into crypto/bio.
ok miod@
Diffstat (limited to 'src')
-rw-r--r-- | src/lib/libcrypto/bio/b_sock.c | 38 | ||||
-rw-r--r-- | src/lib/libcrypto/bio/bss_dgram.c | 114 | ||||
-rw-r--r-- | src/lib/libcrypto/bio/bss_fd.c | 6 | ||||
-rw-r--r-- | src/lib/libcrypto/bio/bss_file.c | 8 | ||||
-rw-r--r-- | src/lib/libcrypto/bio/bss_sock.c | 6 | ||||
-rw-r--r-- | src/lib/libssl/src/crypto/bio/b_sock.c | 38 | ||||
-rw-r--r-- | src/lib/libssl/src/crypto/bio/bss_dgram.c | 114 | ||||
-rw-r--r-- | src/lib/libssl/src/crypto/bio/bss_fd.c | 6 | ||||
-rw-r--r-- | src/lib/libssl/src/crypto/bio/bss_file.c | 8 | ||||
-rw-r--r-- | src/lib/libssl/src/crypto/bio/bss_sock.c | 6 |
10 files changed, 6 insertions, 338 deletions
diff --git a/src/lib/libcrypto/bio/b_sock.c b/src/lib/libcrypto/bio/b_sock.c index d739452580..2a9159ec55 100644 --- a/src/lib/libcrypto/bio/b_sock.c +++ b/src/lib/libcrypto/bio/b_sock.c | |||
@@ -457,27 +457,6 @@ end: | |||
457 | int | 457 | int |
458 | BIO_sock_init(void) | 458 | BIO_sock_init(void) |
459 | { | 459 | { |
460 | #ifdef OPENSSL_SYS_WINDOWS | ||
461 | static struct WSAData wsa_state; | ||
462 | |||
463 | if (!wsa_init_done) { | ||
464 | int err; | ||
465 | |||
466 | wsa_init_done = 1; | ||
467 | memset(&wsa_state, 0, sizeof(wsa_state)); | ||
468 | /* Not making wsa_state available to the rest of the | ||
469 | * code is formally wrong. But the structures we use | ||
470 | * are [beleived to be] invariable among Winsock DLLs, | ||
471 | * while API availability is [expected to be] probed | ||
472 | * at run-time with DSO_global_lookup. */ | ||
473 | if (WSAStartup(0x0202, &wsa_state) != 0) { | ||
474 | err = WSAGetLastError(); | ||
475 | SYSerr(SYS_F_WSASTARTUP, err); | ||
476 | BIOerr(BIO_F_BIO_SOCK_INIT, BIO_R_WSASTARTUP); | ||
477 | return (-1); | ||
478 | } | ||
479 | } | ||
480 | #endif /* OPENSSL_SYS_WINDOWS */ | ||
481 | #ifdef WATT32 | 460 | #ifdef WATT32 |
482 | extern int _watt_do_exit; | 461 | extern int _watt_do_exit; |
483 | _watt_do_exit = 0; | 462 | _watt_do_exit = 0; |
@@ -509,15 +488,7 @@ BIO_sock_init(void) | |||
509 | void | 488 | void |
510 | BIO_sock_cleanup(void) | 489 | BIO_sock_cleanup(void) |
511 | { | 490 | { |
512 | #ifdef OPENSSL_SYS_WINDOWS | 491 | #if defined(OPENSSL_SYS_NETWARE) && !defined(NETWARE_BSDSOCK) |
513 | if (wsa_init_done) { | ||
514 | wsa_init_done = 0; | ||
515 | #if 0 /* this call is claimed to be non-present in Winsock2 */ | ||
516 | WSACancelBlockingCall(); | ||
517 | #endif | ||
518 | WSACleanup(); | ||
519 | } | ||
520 | #elif defined(OPENSSL_SYS_NETWARE) && !defined(NETWARE_BSDSOCK) | ||
521 | if (wsa_init_done) { | 492 | if (wsa_init_done) { |
522 | wsa_init_done = 0; | 493 | wsa_init_done = 0; |
523 | WSACleanup(); | 494 | WSACleanup(); |
@@ -738,14 +709,7 @@ again: | |||
738 | #ifdef SO_REUSEADDR | 709 | #ifdef SO_REUSEADDR |
739 | err_num = errno; | 710 | err_num = errno; |
740 | if ((bind_mode == BIO_BIND_REUSEADDR_IF_UNUSED) && | 711 | if ((bind_mode == BIO_BIND_REUSEADDR_IF_UNUSED) && |
741 | #ifdef OPENSSL_SYS_WINDOWS | ||
742 | /* Some versions of Windows define EADDRINUSE to | ||
743 | * a dummy value. | ||
744 | */ | ||
745 | (err_num == WSAEADDRINUSE)) | ||
746 | #else | ||
747 | (err_num == EADDRINUSE)) | 712 | (err_num == EADDRINUSE)) |
748 | #endif | ||
749 | { | 713 | { |
750 | client = server; | 714 | client = server; |
751 | if (h == NULL || strcmp(h, "*") == 0) { | 715 | if (h == NULL || strcmp(h, "*") == 0) { |
diff --git a/src/lib/libcrypto/bio/bss_dgram.c b/src/lib/libcrypto/bio/bss_dgram.c index 330f6fc404..328bab9ce3 100644 --- a/src/lib/libcrypto/bio/bss_dgram.c +++ b/src/lib/libcrypto/bio/bss_dgram.c | |||
@@ -279,25 +279,12 @@ dgram_adjust_rcv_timeout(BIO *b) | |||
279 | struct timeval timenow, timeleft; | 279 | struct timeval timenow, timeleft; |
280 | 280 | ||
281 | /* Read current socket timeout */ | 281 | /* Read current socket timeout */ |
282 | #ifdef OPENSSL_SYS_WINDOWS | ||
283 | int timeout; | ||
284 | |||
285 | sz.i = sizeof(timeout); | ||
286 | if (getsockopt(b->num, SOL_SOCKET, SO_RCVTIMEO, | ||
287 | (void*)&timeout, &sz.i) < 0) { | ||
288 | perror("getsockopt"); | ||
289 | } else { | ||
290 | data->socket_timeout.tv_sec = timeout / 1000; | ||
291 | data->socket_timeout.tv_usec = (timeout % 1000) * 1000; | ||
292 | } | ||
293 | #else | ||
294 | sz.i = sizeof(data->socket_timeout); | 282 | sz.i = sizeof(data->socket_timeout); |
295 | if (getsockopt(b->num, SOL_SOCKET, SO_RCVTIMEO, | 283 | if (getsockopt(b->num, SOL_SOCKET, SO_RCVTIMEO, |
296 | &(data->socket_timeout), (void *)&sz) < 0) { | 284 | &(data->socket_timeout), (void *)&sz) < 0) { |
297 | perror("getsockopt"); | 285 | perror("getsockopt"); |
298 | } else if (sizeof(sz.s) != sizeof(sz.i) && sz.i == 0) | 286 | } else if (sizeof(sz.s) != sizeof(sz.i) && sz.i == 0) |
299 | OPENSSL_assert(sz.s <= sizeof(data->socket_timeout)); | 287 | OPENSSL_assert(sz.s <= sizeof(data->socket_timeout)); |
300 | #endif | ||
301 | 288 | ||
302 | /* Get current time */ | 289 | /* Get current time */ |
303 | get_current_time(&timenow); | 290 | get_current_time(&timenow); |
@@ -324,18 +311,10 @@ dgram_adjust_rcv_timeout(BIO *b) | |||
324 | (data->socket_timeout.tv_sec > timeleft.tv_sec) || | 311 | (data->socket_timeout.tv_sec > timeleft.tv_sec) || |
325 | (data->socket_timeout.tv_sec == timeleft.tv_sec && | 312 | (data->socket_timeout.tv_sec == timeleft.tv_sec && |
326 | data->socket_timeout.tv_usec >= timeleft.tv_usec)) { | 313 | data->socket_timeout.tv_usec >= timeleft.tv_usec)) { |
327 | #ifdef OPENSSL_SYS_WINDOWS | ||
328 | timeout = timeleft.tv_sec * 1000 + timeleft.tv_usec / 1000; | ||
329 | if (setsockopt(b->num, SOL_SOCKET, SO_RCVTIMEO, | ||
330 | (void*)&timeout, sizeof(timeout)) < 0) { | ||
331 | perror("setsockopt"); | ||
332 | } | ||
333 | #else | ||
334 | if (setsockopt(b->num, SOL_SOCKET, SO_RCVTIMEO, | 314 | if (setsockopt(b->num, SOL_SOCKET, SO_RCVTIMEO, |
335 | &timeleft, sizeof(struct timeval)) < 0) { | 315 | &timeleft, sizeof(struct timeval)) < 0) { |
336 | perror("setsockopt"); | 316 | perror("setsockopt"); |
337 | } | 317 | } |
338 | #endif | ||
339 | } | 318 | } |
340 | } | 319 | } |
341 | #endif | 320 | #endif |
@@ -349,19 +328,10 @@ dgram_reset_rcv_timeout(BIO *b) | |||
349 | 328 | ||
350 | /* Is a timer active? */ | 329 | /* Is a timer active? */ |
351 | if (data->next_timeout.tv_sec > 0 || data->next_timeout.tv_usec > 0) { | 330 | if (data->next_timeout.tv_sec > 0 || data->next_timeout.tv_usec > 0) { |
352 | #ifdef OPENSSL_SYS_WINDOWS | ||
353 | int timeout = data->socket_timeout.tv_sec * 1000 + | ||
354 | data->socket_timeout.tv_usec / 1000; | ||
355 | if (setsockopt(b->num, SOL_SOCKET, SO_RCVTIMEO, | ||
356 | (void*)&timeout, sizeof(timeout)) < 0) { | ||
357 | perror("setsockopt"); | ||
358 | } | ||
359 | #else | ||
360 | if (setsockopt(b->num, SOL_SOCKET, SO_RCVTIMEO, | 331 | if (setsockopt(b->num, SOL_SOCKET, SO_RCVTIMEO, |
361 | &(data->socket_timeout), sizeof(struct timeval)) < 0) { | 332 | &(data->socket_timeout), sizeof(struct timeval)) < 0) { |
362 | perror("setsockopt"); | 333 | perror("setsockopt"); |
363 | } | 334 | } |
364 | #endif | ||
365 | } | 335 | } |
366 | #endif | 336 | #endif |
367 | } | 337 | } |
@@ -716,23 +686,11 @@ default: | |||
716 | break; | 686 | break; |
717 | #if defined(SO_RCVTIMEO) | 687 | #if defined(SO_RCVTIMEO) |
718 | case BIO_CTRL_DGRAM_SET_RECV_TIMEOUT: | 688 | case BIO_CTRL_DGRAM_SET_RECV_TIMEOUT: |
719 | #ifdef OPENSSL_SYS_WINDOWS | ||
720 | { | ||
721 | struct timeval *tv = (struct timeval *)ptr; | ||
722 | int timeout = tv->tv_sec * 1000 + tv->tv_usec/1000; | ||
723 | if (setsockopt(b->num, SOL_SOCKET, SO_RCVTIMEO, | ||
724 | (void*)&timeout, sizeof(timeout)) < 0) { | ||
725 | perror("setsockopt"); | ||
726 | ret = -1; | ||
727 | } | ||
728 | } | ||
729 | #else | ||
730 | if (setsockopt(b->num, SOL_SOCKET, SO_RCVTIMEO, ptr, | 689 | if (setsockopt(b->num, SOL_SOCKET, SO_RCVTIMEO, ptr, |
731 | sizeof(struct timeval)) < 0) { | 690 | sizeof(struct timeval)) < 0) { |
732 | perror("setsockopt"); | 691 | perror("setsockopt"); |
733 | ret = -1; | 692 | ret = -1; |
734 | } | 693 | } |
735 | #endif | ||
736 | break; | 694 | break; |
737 | case BIO_CTRL_DGRAM_GET_RECV_TIMEOUT: | 695 | case BIO_CTRL_DGRAM_GET_RECV_TIMEOUT: |
738 | { | 696 | { |
@@ -740,21 +698,6 @@ default: | |||
740 | size_t s; | 698 | size_t s; |
741 | int i; | 699 | int i; |
742 | } sz = {0}; | 700 | } sz = {0}; |
743 | #ifdef OPENSSL_SYS_WINDOWS | ||
744 | int timeout; | ||
745 | struct timeval *tv = (struct timeval *)ptr; | ||
746 | |||
747 | sz.i = sizeof(timeout); | ||
748 | if (getsockopt(b->num, SOL_SOCKET, SO_RCVTIMEO, | ||
749 | (void*)&timeout, &sz.i) < 0) { | ||
750 | perror("getsockopt"); | ||
751 | ret = -1; | ||
752 | } else { | ||
753 | tv->tv_sec = timeout / 1000; | ||
754 | tv->tv_usec = (timeout % 1000) * 1000; | ||
755 | ret = sizeof(*tv); | ||
756 | } | ||
757 | #else | ||
758 | sz.i = sizeof(struct timeval); | 701 | sz.i = sizeof(struct timeval); |
759 | if (getsockopt(b->num, SOL_SOCKET, SO_RCVTIMEO, | 702 | if (getsockopt(b->num, SOL_SOCKET, SO_RCVTIMEO, |
760 | ptr, (void *)&sz) < 0) { | 703 | ptr, (void *)&sz) < 0) { |
@@ -765,29 +708,16 @@ default: | |||
765 | ret = (int)sz.s; | 708 | ret = (int)sz.s; |
766 | } else | 709 | } else |
767 | ret = sz.i; | 710 | ret = sz.i; |
768 | #endif | ||
769 | } | 711 | } |
770 | break; | 712 | break; |
771 | #endif | 713 | #endif |
772 | #if defined(SO_SNDTIMEO) | 714 | #if defined(SO_SNDTIMEO) |
773 | case BIO_CTRL_DGRAM_SET_SEND_TIMEOUT: | 715 | case BIO_CTRL_DGRAM_SET_SEND_TIMEOUT: |
774 | #ifdef OPENSSL_SYS_WINDOWS | ||
775 | { | ||
776 | struct timeval *tv = (struct timeval *)ptr; | ||
777 | int timeout = tv->tv_sec * 1000 + tv->tv_usec/1000; | ||
778 | if (setsockopt(b->num, SOL_SOCKET, SO_SNDTIMEO, | ||
779 | (void*)&timeout, sizeof(timeout)) < 0) { | ||
780 | perror("setsockopt"); | ||
781 | ret = -1; | ||
782 | } | ||
783 | } | ||
784 | #else | ||
785 | if (setsockopt(b->num, SOL_SOCKET, SO_SNDTIMEO, ptr, | 716 | if (setsockopt(b->num, SOL_SOCKET, SO_SNDTIMEO, ptr, |
786 | sizeof(struct timeval)) < 0) { | 717 | sizeof(struct timeval)) < 0) { |
787 | perror("setsockopt"); | 718 | perror("setsockopt"); |
788 | ret = -1; | 719 | ret = -1; |
789 | } | 720 | } |
790 | #endif | ||
791 | break; | 721 | break; |
792 | case BIO_CTRL_DGRAM_GET_SEND_TIMEOUT: | 722 | case BIO_CTRL_DGRAM_GET_SEND_TIMEOUT: |
793 | { | 723 | { |
@@ -795,21 +725,6 @@ default: | |||
795 | size_t s; | 725 | size_t s; |
796 | int i; | 726 | int i; |
797 | } sz = {0}; | 727 | } sz = {0}; |
798 | #ifdef OPENSSL_SYS_WINDOWS | ||
799 | int timeout; | ||
800 | struct timeval *tv = (struct timeval *)ptr; | ||
801 | |||
802 | sz.i = sizeof(timeout); | ||
803 | if (getsockopt(b->num, SOL_SOCKET, SO_SNDTIMEO, | ||
804 | (void*)&timeout, &sz.i) < 0) { | ||
805 | perror("getsockopt"); | ||
806 | ret = -1; | ||
807 | } else { | ||
808 | tv->tv_sec = timeout / 1000; | ||
809 | tv->tv_usec = (timeout % 1000) * 1000; | ||
810 | ret = sizeof(*tv); | ||
811 | } | ||
812 | #else | ||
813 | sz.i = sizeof(struct timeval); | 728 | sz.i = sizeof(struct timeval); |
814 | if (getsockopt(b->num, SOL_SOCKET, SO_SNDTIMEO, | 729 | if (getsockopt(b->num, SOL_SOCKET, SO_SNDTIMEO, |
815 | ptr, (void *)&sz) < 0) { | 730 | ptr, (void *)&sz) < 0) { |
@@ -820,19 +735,13 @@ default: | |||
820 | ret = (int)sz.s; | 735 | ret = (int)sz.s; |
821 | } else | 736 | } else |
822 | ret = sz.i; | 737 | ret = sz.i; |
823 | #endif | ||
824 | } | 738 | } |
825 | break; | 739 | break; |
826 | #endif | 740 | #endif |
827 | case BIO_CTRL_DGRAM_GET_SEND_TIMER_EXP: | 741 | case BIO_CTRL_DGRAM_GET_SEND_TIMER_EXP: |
828 | /* fall-through */ | 742 | /* fall-through */ |
829 | case BIO_CTRL_DGRAM_GET_RECV_TIMER_EXP: | 743 | case BIO_CTRL_DGRAM_GET_RECV_TIMER_EXP: |
830 | #ifdef OPENSSL_SYS_WINDOWS | 744 | if (data->_errno == EAGAIN) { |
831 | if (data->_errno == WSAETIMEDOUT) | ||
832 | #else | ||
833 | if (data->_errno == EAGAIN) | ||
834 | #endif | ||
835 | { | ||
836 | ret = 1; | 745 | ret = 1; |
837 | data->_errno = 0; | 746 | data->_errno = 0; |
838 | } else | 747 | } else |
@@ -1769,16 +1678,6 @@ BIO_dgram_should_retry(int i) | |||
1769 | 1678 | ||
1770 | if ((i == 0) || (i == -1)) { | 1679 | if ((i == 0) || (i == -1)) { |
1771 | err = errno; | 1680 | err = errno; |
1772 | |||
1773 | #if defined(OPENSSL_SYS_WINDOWS) | ||
1774 | /* If the socket return value (i) is -1 | ||
1775 | * and err is unexpectedly 0 at this point, | ||
1776 | * the error code was overwritten by | ||
1777 | * another system call before this error | ||
1778 | * handling is called. | ||
1779 | */ | ||
1780 | #endif | ||
1781 | |||
1782 | return (BIO_dgram_non_fatal_error(err)); | 1681 | return (BIO_dgram_non_fatal_error(err)); |
1783 | } | 1682 | } |
1784 | return (0); | 1683 | return (0); |
@@ -1788,17 +1687,6 @@ int | |||
1788 | BIO_dgram_non_fatal_error(int err) | 1687 | BIO_dgram_non_fatal_error(int err) |
1789 | { | 1688 | { |
1790 | switch (err) { | 1689 | switch (err) { |
1791 | #if defined(OPENSSL_SYS_WINDOWS) | ||
1792 | # if defined(WSAEWOULDBLOCK) | ||
1793 | case WSAEWOULDBLOCK: | ||
1794 | # endif | ||
1795 | |||
1796 | # if 0 /* This appears to always be an error */ | ||
1797 | # if defined(WSAENOTCONN) | ||
1798 | case WSAENOTCONN: | ||
1799 | # endif | ||
1800 | # endif | ||
1801 | #endif | ||
1802 | 1690 | ||
1803 | #ifdef EWOULDBLOCK | 1691 | #ifdef EWOULDBLOCK |
1804 | # ifdef WSAEWOULDBLOCK | 1692 | # ifdef WSAEWOULDBLOCK |
diff --git a/src/lib/libcrypto/bio/bss_fd.c b/src/lib/libcrypto/bio/bss_fd.c index 35ddd61359..86757154e8 100644 --- a/src/lib/libcrypto/bio/bss_fd.c +++ b/src/lib/libcrypto/bio/bss_fd.c | |||
@@ -261,12 +261,6 @@ BIO_fd_should_retry(int i) | |||
261 | 261 | ||
262 | if ((i == 0) || (i == -1)) { | 262 | if ((i == 0) || (i == -1)) { |
263 | err = errno; | 263 | err = errno; |
264 | |||
265 | #if defined(OPENSSL_SYS_WINDOWS) && 0 /* more microsoft stupidity? perhaps not? Ben 4/1/99 */ | ||
266 | if ((i == -1) && (err == 0)) | ||
267 | return (1); | ||
268 | #endif | ||
269 | |||
270 | return (BIO_fd_non_fatal_error(err)); | 264 | return (BIO_fd_non_fatal_error(err)); |
271 | } | 265 | } |
272 | return (0); | 266 | return (0); |
diff --git a/src/lib/libcrypto/bio/bss_file.c b/src/lib/libcrypto/bio/bss_file.c index 794f503a69..982317b34a 100644 --- a/src/lib/libcrypto/bio/bss_file.c +++ b/src/lib/libcrypto/bio/bss_file.c | |||
@@ -320,13 +320,7 @@ file_ctrl(BIO *b, int cmd, long num, void *ptr) | |||
320 | else | 320 | else |
321 | #endif | 321 | #endif |
322 | { | 322 | { |
323 | #if defined(OPENSSL_SYS_WINDOWS) | 323 | #if defined(OPENSSL_SYS_NETWARE) && defined(NETWARE_CLIB) |
324 | int fd = _fileno((FILE*)ptr); | ||
325 | if (num & BIO_FP_TEXT) | ||
326 | _setmode(fd, _O_TEXT); | ||
327 | else | ||
328 | _setmode(fd, _O_BINARY); | ||
329 | #elif defined(OPENSSL_SYS_NETWARE) && defined(NETWARE_CLIB) | ||
330 | int fd = fileno((FILE*)ptr); | 324 | int fd = fileno((FILE*)ptr); |
331 | /* Under CLib there are differences in file modes */ | 325 | /* Under CLib there are differences in file modes */ |
332 | if (num & BIO_FP_TEXT) | 326 | if (num & BIO_FP_TEXT) |
diff --git a/src/lib/libcrypto/bio/bss_sock.c b/src/lib/libcrypto/bio/bss_sock.c index f6d3bf7365..30640d8f96 100644 --- a/src/lib/libcrypto/bio/bss_sock.c +++ b/src/lib/libcrypto/bio/bss_sock.c | |||
@@ -224,12 +224,6 @@ BIO_sock_should_retry(int i) | |||
224 | 224 | ||
225 | if ((i == 0) || (i == -1)) { | 225 | if ((i == 0) || (i == -1)) { |
226 | err = errno; | 226 | err = errno; |
227 | |||
228 | #if defined(OPENSSL_SYS_WINDOWS) && 0 /* more microsoft stupidity? perhaps not? Ben 4/1/99 */ | ||
229 | if ((i == -1) && (err == 0)) | ||
230 | return (1); | ||
231 | #endif | ||
232 | |||
233 | return (BIO_sock_non_fatal_error(err)); | 227 | return (BIO_sock_non_fatal_error(err)); |
234 | } | 228 | } |
235 | return (0); | 229 | return (0); |
diff --git a/src/lib/libssl/src/crypto/bio/b_sock.c b/src/lib/libssl/src/crypto/bio/b_sock.c index d739452580..2a9159ec55 100644 --- a/src/lib/libssl/src/crypto/bio/b_sock.c +++ b/src/lib/libssl/src/crypto/bio/b_sock.c | |||
@@ -457,27 +457,6 @@ end: | |||
457 | int | 457 | int |
458 | BIO_sock_init(void) | 458 | BIO_sock_init(void) |
459 | { | 459 | { |
460 | #ifdef OPENSSL_SYS_WINDOWS | ||
461 | static struct WSAData wsa_state; | ||
462 | |||
463 | if (!wsa_init_done) { | ||
464 | int err; | ||
465 | |||
466 | wsa_init_done = 1; | ||
467 | memset(&wsa_state, 0, sizeof(wsa_state)); | ||
468 | /* Not making wsa_state available to the rest of the | ||
469 | * code is formally wrong. But the structures we use | ||
470 | * are [beleived to be] invariable among Winsock DLLs, | ||
471 | * while API availability is [expected to be] probed | ||
472 | * at run-time with DSO_global_lookup. */ | ||
473 | if (WSAStartup(0x0202, &wsa_state) != 0) { | ||
474 | err = WSAGetLastError(); | ||
475 | SYSerr(SYS_F_WSASTARTUP, err); | ||
476 | BIOerr(BIO_F_BIO_SOCK_INIT, BIO_R_WSASTARTUP); | ||
477 | return (-1); | ||
478 | } | ||
479 | } | ||
480 | #endif /* OPENSSL_SYS_WINDOWS */ | ||
481 | #ifdef WATT32 | 460 | #ifdef WATT32 |
482 | extern int _watt_do_exit; | 461 | extern int _watt_do_exit; |
483 | _watt_do_exit = 0; | 462 | _watt_do_exit = 0; |
@@ -509,15 +488,7 @@ BIO_sock_init(void) | |||
509 | void | 488 | void |
510 | BIO_sock_cleanup(void) | 489 | BIO_sock_cleanup(void) |
511 | { | 490 | { |
512 | #ifdef OPENSSL_SYS_WINDOWS | 491 | #if defined(OPENSSL_SYS_NETWARE) && !defined(NETWARE_BSDSOCK) |
513 | if (wsa_init_done) { | ||
514 | wsa_init_done = 0; | ||
515 | #if 0 /* this call is claimed to be non-present in Winsock2 */ | ||
516 | WSACancelBlockingCall(); | ||
517 | #endif | ||
518 | WSACleanup(); | ||
519 | } | ||
520 | #elif defined(OPENSSL_SYS_NETWARE) && !defined(NETWARE_BSDSOCK) | ||
521 | if (wsa_init_done) { | 492 | if (wsa_init_done) { |
522 | wsa_init_done = 0; | 493 | wsa_init_done = 0; |
523 | WSACleanup(); | 494 | WSACleanup(); |
@@ -738,14 +709,7 @@ again: | |||
738 | #ifdef SO_REUSEADDR | 709 | #ifdef SO_REUSEADDR |
739 | err_num = errno; | 710 | err_num = errno; |
740 | if ((bind_mode == BIO_BIND_REUSEADDR_IF_UNUSED) && | 711 | if ((bind_mode == BIO_BIND_REUSEADDR_IF_UNUSED) && |
741 | #ifdef OPENSSL_SYS_WINDOWS | ||
742 | /* Some versions of Windows define EADDRINUSE to | ||
743 | * a dummy value. | ||
744 | */ | ||
745 | (err_num == WSAEADDRINUSE)) | ||
746 | #else | ||
747 | (err_num == EADDRINUSE)) | 712 | (err_num == EADDRINUSE)) |
748 | #endif | ||
749 | { | 713 | { |
750 | client = server; | 714 | client = server; |
751 | if (h == NULL || strcmp(h, "*") == 0) { | 715 | if (h == NULL || strcmp(h, "*") == 0) { |
diff --git a/src/lib/libssl/src/crypto/bio/bss_dgram.c b/src/lib/libssl/src/crypto/bio/bss_dgram.c index 330f6fc404..328bab9ce3 100644 --- a/src/lib/libssl/src/crypto/bio/bss_dgram.c +++ b/src/lib/libssl/src/crypto/bio/bss_dgram.c | |||
@@ -279,25 +279,12 @@ dgram_adjust_rcv_timeout(BIO *b) | |||
279 | struct timeval timenow, timeleft; | 279 | struct timeval timenow, timeleft; |
280 | 280 | ||
281 | /* Read current socket timeout */ | 281 | /* Read current socket timeout */ |
282 | #ifdef OPENSSL_SYS_WINDOWS | ||
283 | int timeout; | ||
284 | |||
285 | sz.i = sizeof(timeout); | ||
286 | if (getsockopt(b->num, SOL_SOCKET, SO_RCVTIMEO, | ||
287 | (void*)&timeout, &sz.i) < 0) { | ||
288 | perror("getsockopt"); | ||
289 | } else { | ||
290 | data->socket_timeout.tv_sec = timeout / 1000; | ||
291 | data->socket_timeout.tv_usec = (timeout % 1000) * 1000; | ||
292 | } | ||
293 | #else | ||
294 | sz.i = sizeof(data->socket_timeout); | 282 | sz.i = sizeof(data->socket_timeout); |
295 | if (getsockopt(b->num, SOL_SOCKET, SO_RCVTIMEO, | 283 | if (getsockopt(b->num, SOL_SOCKET, SO_RCVTIMEO, |
296 | &(data->socket_timeout), (void *)&sz) < 0) { | 284 | &(data->socket_timeout), (void *)&sz) < 0) { |
297 | perror("getsockopt"); | 285 | perror("getsockopt"); |
298 | } else if (sizeof(sz.s) != sizeof(sz.i) && sz.i == 0) | 286 | } else if (sizeof(sz.s) != sizeof(sz.i) && sz.i == 0) |
299 | OPENSSL_assert(sz.s <= sizeof(data->socket_timeout)); | 287 | OPENSSL_assert(sz.s <= sizeof(data->socket_timeout)); |
300 | #endif | ||
301 | 288 | ||
302 | /* Get current time */ | 289 | /* Get current time */ |
303 | get_current_time(&timenow); | 290 | get_current_time(&timenow); |
@@ -324,18 +311,10 @@ dgram_adjust_rcv_timeout(BIO *b) | |||
324 | (data->socket_timeout.tv_sec > timeleft.tv_sec) || | 311 | (data->socket_timeout.tv_sec > timeleft.tv_sec) || |
325 | (data->socket_timeout.tv_sec == timeleft.tv_sec && | 312 | (data->socket_timeout.tv_sec == timeleft.tv_sec && |
326 | data->socket_timeout.tv_usec >= timeleft.tv_usec)) { | 313 | data->socket_timeout.tv_usec >= timeleft.tv_usec)) { |
327 | #ifdef OPENSSL_SYS_WINDOWS | ||
328 | timeout = timeleft.tv_sec * 1000 + timeleft.tv_usec / 1000; | ||
329 | if (setsockopt(b->num, SOL_SOCKET, SO_RCVTIMEO, | ||
330 | (void*)&timeout, sizeof(timeout)) < 0) { | ||
331 | perror("setsockopt"); | ||
332 | } | ||
333 | #else | ||
334 | if (setsockopt(b->num, SOL_SOCKET, SO_RCVTIMEO, | 314 | if (setsockopt(b->num, SOL_SOCKET, SO_RCVTIMEO, |
335 | &timeleft, sizeof(struct timeval)) < 0) { | 315 | &timeleft, sizeof(struct timeval)) < 0) { |
336 | perror("setsockopt"); | 316 | perror("setsockopt"); |
337 | } | 317 | } |
338 | #endif | ||
339 | } | 318 | } |
340 | } | 319 | } |
341 | #endif | 320 | #endif |
@@ -349,19 +328,10 @@ dgram_reset_rcv_timeout(BIO *b) | |||
349 | 328 | ||
350 | /* Is a timer active? */ | 329 | /* Is a timer active? */ |
351 | if (data->next_timeout.tv_sec > 0 || data->next_timeout.tv_usec > 0) { | 330 | if (data->next_timeout.tv_sec > 0 || data->next_timeout.tv_usec > 0) { |
352 | #ifdef OPENSSL_SYS_WINDOWS | ||
353 | int timeout = data->socket_timeout.tv_sec * 1000 + | ||
354 | data->socket_timeout.tv_usec / 1000; | ||
355 | if (setsockopt(b->num, SOL_SOCKET, SO_RCVTIMEO, | ||
356 | (void*)&timeout, sizeof(timeout)) < 0) { | ||
357 | perror("setsockopt"); | ||
358 | } | ||
359 | #else | ||
360 | if (setsockopt(b->num, SOL_SOCKET, SO_RCVTIMEO, | 331 | if (setsockopt(b->num, SOL_SOCKET, SO_RCVTIMEO, |
361 | &(data->socket_timeout), sizeof(struct timeval)) < 0) { | 332 | &(data->socket_timeout), sizeof(struct timeval)) < 0) { |
362 | perror("setsockopt"); | 333 | perror("setsockopt"); |
363 | } | 334 | } |
364 | #endif | ||
365 | } | 335 | } |
366 | #endif | 336 | #endif |
367 | } | 337 | } |
@@ -716,23 +686,11 @@ default: | |||
716 | break; | 686 | break; |
717 | #if defined(SO_RCVTIMEO) | 687 | #if defined(SO_RCVTIMEO) |
718 | case BIO_CTRL_DGRAM_SET_RECV_TIMEOUT: | 688 | case BIO_CTRL_DGRAM_SET_RECV_TIMEOUT: |
719 | #ifdef OPENSSL_SYS_WINDOWS | ||
720 | { | ||
721 | struct timeval *tv = (struct timeval *)ptr; | ||
722 | int timeout = tv->tv_sec * 1000 + tv->tv_usec/1000; | ||
723 | if (setsockopt(b->num, SOL_SOCKET, SO_RCVTIMEO, | ||
724 | (void*)&timeout, sizeof(timeout)) < 0) { | ||
725 | perror("setsockopt"); | ||
726 | ret = -1; | ||
727 | } | ||
728 | } | ||
729 | #else | ||
730 | if (setsockopt(b->num, SOL_SOCKET, SO_RCVTIMEO, ptr, | 689 | if (setsockopt(b->num, SOL_SOCKET, SO_RCVTIMEO, ptr, |
731 | sizeof(struct timeval)) < 0) { | 690 | sizeof(struct timeval)) < 0) { |
732 | perror("setsockopt"); | 691 | perror("setsockopt"); |
733 | ret = -1; | 692 | ret = -1; |
734 | } | 693 | } |
735 | #endif | ||
736 | break; | 694 | break; |
737 | case BIO_CTRL_DGRAM_GET_RECV_TIMEOUT: | 695 | case BIO_CTRL_DGRAM_GET_RECV_TIMEOUT: |
738 | { | 696 | { |
@@ -740,21 +698,6 @@ default: | |||
740 | size_t s; | 698 | size_t s; |
741 | int i; | 699 | int i; |
742 | } sz = {0}; | 700 | } sz = {0}; |
743 | #ifdef OPENSSL_SYS_WINDOWS | ||
744 | int timeout; | ||
745 | struct timeval *tv = (struct timeval *)ptr; | ||
746 | |||
747 | sz.i = sizeof(timeout); | ||
748 | if (getsockopt(b->num, SOL_SOCKET, SO_RCVTIMEO, | ||
749 | (void*)&timeout, &sz.i) < 0) { | ||
750 | perror("getsockopt"); | ||
751 | ret = -1; | ||
752 | } else { | ||
753 | tv->tv_sec = timeout / 1000; | ||
754 | tv->tv_usec = (timeout % 1000) * 1000; | ||
755 | ret = sizeof(*tv); | ||
756 | } | ||
757 | #else | ||
758 | sz.i = sizeof(struct timeval); | 701 | sz.i = sizeof(struct timeval); |
759 | if (getsockopt(b->num, SOL_SOCKET, SO_RCVTIMEO, | 702 | if (getsockopt(b->num, SOL_SOCKET, SO_RCVTIMEO, |
760 | ptr, (void *)&sz) < 0) { | 703 | ptr, (void *)&sz) < 0) { |
@@ -765,29 +708,16 @@ default: | |||
765 | ret = (int)sz.s; | 708 | ret = (int)sz.s; |
766 | } else | 709 | } else |
767 | ret = sz.i; | 710 | ret = sz.i; |
768 | #endif | ||
769 | } | 711 | } |
770 | break; | 712 | break; |
771 | #endif | 713 | #endif |
772 | #if defined(SO_SNDTIMEO) | 714 | #if defined(SO_SNDTIMEO) |
773 | case BIO_CTRL_DGRAM_SET_SEND_TIMEOUT: | 715 | case BIO_CTRL_DGRAM_SET_SEND_TIMEOUT: |
774 | #ifdef OPENSSL_SYS_WINDOWS | ||
775 | { | ||
776 | struct timeval *tv = (struct timeval *)ptr; | ||
777 | int timeout = tv->tv_sec * 1000 + tv->tv_usec/1000; | ||
778 | if (setsockopt(b->num, SOL_SOCKET, SO_SNDTIMEO, | ||
779 | (void*)&timeout, sizeof(timeout)) < 0) { | ||
780 | perror("setsockopt"); | ||
781 | ret = -1; | ||
782 | } | ||
783 | } | ||
784 | #else | ||
785 | if (setsockopt(b->num, SOL_SOCKET, SO_SNDTIMEO, ptr, | 716 | if (setsockopt(b->num, SOL_SOCKET, SO_SNDTIMEO, ptr, |
786 | sizeof(struct timeval)) < 0) { | 717 | sizeof(struct timeval)) < 0) { |
787 | perror("setsockopt"); | 718 | perror("setsockopt"); |
788 | ret = -1; | 719 | ret = -1; |
789 | } | 720 | } |
790 | #endif | ||
791 | break; | 721 | break; |
792 | case BIO_CTRL_DGRAM_GET_SEND_TIMEOUT: | 722 | case BIO_CTRL_DGRAM_GET_SEND_TIMEOUT: |
793 | { | 723 | { |
@@ -795,21 +725,6 @@ default: | |||
795 | size_t s; | 725 | size_t s; |
796 | int i; | 726 | int i; |
797 | } sz = {0}; | 727 | } sz = {0}; |
798 | #ifdef OPENSSL_SYS_WINDOWS | ||
799 | int timeout; | ||
800 | struct timeval *tv = (struct timeval *)ptr; | ||
801 | |||
802 | sz.i = sizeof(timeout); | ||
803 | if (getsockopt(b->num, SOL_SOCKET, SO_SNDTIMEO, | ||
804 | (void*)&timeout, &sz.i) < 0) { | ||
805 | perror("getsockopt"); | ||
806 | ret = -1; | ||
807 | } else { | ||
808 | tv->tv_sec = timeout / 1000; | ||
809 | tv->tv_usec = (timeout % 1000) * 1000; | ||
810 | ret = sizeof(*tv); | ||
811 | } | ||
812 | #else | ||
813 | sz.i = sizeof(struct timeval); | 728 | sz.i = sizeof(struct timeval); |
814 | if (getsockopt(b->num, SOL_SOCKET, SO_SNDTIMEO, | 729 | if (getsockopt(b->num, SOL_SOCKET, SO_SNDTIMEO, |
815 | ptr, (void *)&sz) < 0) { | 730 | ptr, (void *)&sz) < 0) { |
@@ -820,19 +735,13 @@ default: | |||
820 | ret = (int)sz.s; | 735 | ret = (int)sz.s; |
821 | } else | 736 | } else |
822 | ret = sz.i; | 737 | ret = sz.i; |
823 | #endif | ||
824 | } | 738 | } |
825 | break; | 739 | break; |
826 | #endif | 740 | #endif |
827 | case BIO_CTRL_DGRAM_GET_SEND_TIMER_EXP: | 741 | case BIO_CTRL_DGRAM_GET_SEND_TIMER_EXP: |
828 | /* fall-through */ | 742 | /* fall-through */ |
829 | case BIO_CTRL_DGRAM_GET_RECV_TIMER_EXP: | 743 | case BIO_CTRL_DGRAM_GET_RECV_TIMER_EXP: |
830 | #ifdef OPENSSL_SYS_WINDOWS | 744 | if (data->_errno == EAGAIN) { |
831 | if (data->_errno == WSAETIMEDOUT) | ||
832 | #else | ||
833 | if (data->_errno == EAGAIN) | ||
834 | #endif | ||
835 | { | ||
836 | ret = 1; | 745 | ret = 1; |
837 | data->_errno = 0; | 746 | data->_errno = 0; |
838 | } else | 747 | } else |
@@ -1769,16 +1678,6 @@ BIO_dgram_should_retry(int i) | |||
1769 | 1678 | ||
1770 | if ((i == 0) || (i == -1)) { | 1679 | if ((i == 0) || (i == -1)) { |
1771 | err = errno; | 1680 | err = errno; |
1772 | |||
1773 | #if defined(OPENSSL_SYS_WINDOWS) | ||
1774 | /* If the socket return value (i) is -1 | ||
1775 | * and err is unexpectedly 0 at this point, | ||
1776 | * the error code was overwritten by | ||
1777 | * another system call before this error | ||
1778 | * handling is called. | ||
1779 | */ | ||
1780 | #endif | ||
1781 | |||
1782 | return (BIO_dgram_non_fatal_error(err)); | 1681 | return (BIO_dgram_non_fatal_error(err)); |
1783 | } | 1682 | } |
1784 | return (0); | 1683 | return (0); |
@@ -1788,17 +1687,6 @@ int | |||
1788 | BIO_dgram_non_fatal_error(int err) | 1687 | BIO_dgram_non_fatal_error(int err) |
1789 | { | 1688 | { |
1790 | switch (err) { | 1689 | switch (err) { |
1791 | #if defined(OPENSSL_SYS_WINDOWS) | ||
1792 | # if defined(WSAEWOULDBLOCK) | ||
1793 | case WSAEWOULDBLOCK: | ||
1794 | # endif | ||
1795 | |||
1796 | # if 0 /* This appears to always be an error */ | ||
1797 | # if defined(WSAENOTCONN) | ||
1798 | case WSAENOTCONN: | ||
1799 | # endif | ||
1800 | # endif | ||
1801 | #endif | ||
1802 | 1690 | ||
1803 | #ifdef EWOULDBLOCK | 1691 | #ifdef EWOULDBLOCK |
1804 | # ifdef WSAEWOULDBLOCK | 1692 | # ifdef WSAEWOULDBLOCK |
diff --git a/src/lib/libssl/src/crypto/bio/bss_fd.c b/src/lib/libssl/src/crypto/bio/bss_fd.c index 35ddd61359..86757154e8 100644 --- a/src/lib/libssl/src/crypto/bio/bss_fd.c +++ b/src/lib/libssl/src/crypto/bio/bss_fd.c | |||
@@ -261,12 +261,6 @@ BIO_fd_should_retry(int i) | |||
261 | 261 | ||
262 | if ((i == 0) || (i == -1)) { | 262 | if ((i == 0) || (i == -1)) { |
263 | err = errno; | 263 | err = errno; |
264 | |||
265 | #if defined(OPENSSL_SYS_WINDOWS) && 0 /* more microsoft stupidity? perhaps not? Ben 4/1/99 */ | ||
266 | if ((i == -1) && (err == 0)) | ||
267 | return (1); | ||
268 | #endif | ||
269 | |||
270 | return (BIO_fd_non_fatal_error(err)); | 264 | return (BIO_fd_non_fatal_error(err)); |
271 | } | 265 | } |
272 | return (0); | 266 | return (0); |
diff --git a/src/lib/libssl/src/crypto/bio/bss_file.c b/src/lib/libssl/src/crypto/bio/bss_file.c index 794f503a69..982317b34a 100644 --- a/src/lib/libssl/src/crypto/bio/bss_file.c +++ b/src/lib/libssl/src/crypto/bio/bss_file.c | |||
@@ -320,13 +320,7 @@ file_ctrl(BIO *b, int cmd, long num, void *ptr) | |||
320 | else | 320 | else |
321 | #endif | 321 | #endif |
322 | { | 322 | { |
323 | #if defined(OPENSSL_SYS_WINDOWS) | 323 | #if defined(OPENSSL_SYS_NETWARE) && defined(NETWARE_CLIB) |
324 | int fd = _fileno((FILE*)ptr); | ||
325 | if (num & BIO_FP_TEXT) | ||
326 | _setmode(fd, _O_TEXT); | ||
327 | else | ||
328 | _setmode(fd, _O_BINARY); | ||
329 | #elif defined(OPENSSL_SYS_NETWARE) && defined(NETWARE_CLIB) | ||
330 | int fd = fileno((FILE*)ptr); | 324 | int fd = fileno((FILE*)ptr); |
331 | /* Under CLib there are differences in file modes */ | 325 | /* Under CLib there are differences in file modes */ |
332 | if (num & BIO_FP_TEXT) | 326 | if (num & BIO_FP_TEXT) |
diff --git a/src/lib/libssl/src/crypto/bio/bss_sock.c b/src/lib/libssl/src/crypto/bio/bss_sock.c index f6d3bf7365..30640d8f96 100644 --- a/src/lib/libssl/src/crypto/bio/bss_sock.c +++ b/src/lib/libssl/src/crypto/bio/bss_sock.c | |||
@@ -224,12 +224,6 @@ BIO_sock_should_retry(int i) | |||
224 | 224 | ||
225 | if ((i == 0) || (i == -1)) { | 225 | if ((i == 0) || (i == -1)) { |
226 | err = errno; | 226 | err = errno; |
227 | |||
228 | #if defined(OPENSSL_SYS_WINDOWS) && 0 /* more microsoft stupidity? perhaps not? Ben 4/1/99 */ | ||
229 | if ((i == -1) && (err == 0)) | ||
230 | return (1); | ||
231 | #endif | ||
232 | |||
233 | return (BIO_sock_non_fatal_error(err)); | 227 | return (BIO_sock_non_fatal_error(err)); |
234 | } | 228 | } |
235 | return (0); | 229 | return (0); |