X-Git-Url: http://sjero.net/git/?p=wget;a=blobdiff_plain;f=src%2Fopenssl.c;h=a1b35b21cdb6f6344fc8c0cac837900a7c284c08;hp=e0a30fc722ee09c44388feda7c909ad3b0eae2ed;hb=1eb1e76e9ac6f1692f33570f61ff43740f3b44d1;hpb=293008f682e5fa9726136bc121bceadc136c77dc diff --git a/src/openssl.c b/src/openssl.c index e0a30fc7..a1b35b21 100644 --- a/src/openssl.c +++ b/src/openssl.c @@ -1,6 +1,6 @@ /* SSL support via OpenSSL library. Copyright (C) 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, - 2009, 2010 Free Software Foundation, Inc. + 2009, 2010, 2011 Free Software Foundation, Inc. Originally contributed by Christian Fraenkel. This file is part of GNU Wget. @@ -33,9 +33,7 @@ as that of the covered work. */ #include #include -#ifdef HAVE_UNISTD_H -# include -#endif +#include #include #include @@ -48,6 +46,10 @@ as that of the covered work. */ #include "url.h" #include "ssl.h" +#ifdef WINDOWS +# include +#endif + /* Application-wide SSL context. This is common to all SSL connections. */ static SSL_CTX *ssl_ctx; @@ -184,9 +186,11 @@ ssl_init () case secure_protocol_auto: meth = SSLv23_client_method (); break; +#ifndef OPENSSL_NO_SSL2 case secure_protocol_sslv2: meth = SSLv2_client_method (); break; +#endif case secure_protocol_sslv3: meth = SSLv3_client_method (); break; @@ -259,8 +263,9 @@ openssl_read (int fd, char *buf, int bufsize, void *arg) do ret = SSL_read (conn, buf, bufsize); while (ret == -1 - && SSL_get_error (conn, ret) == SSL_ERROR_SYSCALL - && errno == EINTR); + || (SSL_get_error (conn, ret) == SSL_ERROR_SYSCALL + && errno == EINTR)); + return ret; } @@ -283,10 +288,10 @@ openssl_poll (int fd, double timeout, int wait_for, void *arg) { struct openssl_transport_context *ctx = arg; SSL *conn = ctx->conn; - if (timeout == 0) - return 1; if (SSL_pending (conn)) return 1; + if (timeout == 0) + return 1; return select_fd (fd, timeout, wait_for); } @@ -296,6 +301,8 @@ openssl_peek (int fd, char *buf, int bufsize, void *arg) int ret; struct openssl_transport_context *ctx = arg; SSL *conn = ctx->conn; + if (! openssl_poll (fd, 0.0, WAIT_FOR_READ, arg)) + return 0; do ret = SSL_peek (conn, buf, bufsize); while (ret == -1 @@ -398,7 +405,7 @@ ssl_connect_wget (int fd) if (!conn) goto error; #ifndef FD_TO_SOCKET -# define FD_TO_SOCKET(x) (x) +# define FD_TO_SOCKET(X) (X) #endif if (!SSL_set_fd (conn, FD_TO_SOCKET (fd))) goto error;