Changelog
+Daniel (5 May 2006)
+- Roland Blom filed bug report #1481217
+ (http://curl.haxx.se/bug/view.cgi?id=1481217), with follow-ups by Michele
+ Bini and David Byron. libcurl previously wrongly used GetLastError() on
+ windows to get error details after socket-related function calls, when it
+ really should use WSAGetLastError() instead.
+
+ When changing to this, the former function Curl_ourerrno() is now instead
+ called Curl_sockerrno() as it is necessary to only use it to get errno from
+ socket-related functions as otherwise it won't work as intended on Windows.
+
Daniel (4 May 2006)
- Mark Eichin submitted bug report #1480821
(http://curl.haxx.se/bug/view.cgi?id=1480821) He found and identified a
This release includes the following bugfixes:
+ o WSAGetLastError() is now used (better) on Windows
o GnuTLS non-block case that could cause data trashing
o deflate code survives lack of zlib header
o CURLOPT_INTERFACE works with hostname
Dan Fandrich, Ilja van Sprundel, David McCreedy, Tor Arntsen, Xavier Bouchoux,
David Byron, Michele Bini, Ates Goral, Katie Wang, Robson Braga Araujo,
- Ale Vesely, Paul Querna, Gisle Vanem, Mark Eichin
+ Ale Vesely, Paul Querna, Gisle Vanem, Mark Eichin, Roland Blom
Thanks! (and sorry if I forgot to mention someone)
bool *connected);
/*
- * Curl_ourerrno() returns the errno (or equivalent) on this platform to
- * hide platform specific for the function that calls this.
+ * Curl_sockerrno() returns the *socket-related* errno (or equivalent) on this
+ * platform to hide platform specific for the function that calls this.
*/
-int Curl_ourerrno(void)
+int Curl_sockerrno(void)
{
#ifdef WIN32
- return (int)GetLastError();
+ return (int)WSAGetLastError();
#else
return errno;
#endif
if (setsockopt(sockfd, SOL_SOCKET, SO_BINDTODEVICE,
data->set.device, strlen(data->set.device)+1) != 0) {
/* printf("Failed to BINDTODEVICE, socket: %d device: %s error: %s\n",
- sockfd, data->set.device, Curl_strerror(Curl_ourerrno())); */
+ sockfd, data->set.device, Curl_strerror(Curl_sockerrno())); */
infof(data, "SO_BINDTODEVICE %s failed\n",
data->set.device);
/* This is typically "errno 1, error: Operation not permitted" if
break;
} while(1);
- data->state.os_errno = Curl_ourerrno();
+ data->state.os_errno = Curl_sockerrno();
failf(data, "bind failure: %s",
Curl_strerror(conn, data->state.os_errno));
return CURLE_HTTP_PORT_FAILED;
if( -1 == getsockopt(sockfd, SOL_SOCKET, SO_ERROR,
(void *)&err, &errSize))
- err = Curl_ourerrno();
+ err = Curl_sockerrno();
#ifdef _WIN32_WCE
/* Always returns this error, bug in CE? */
#else
(void)sockfd;
if (error)
- *error = Curl_ourerrno();
+ *error = Curl_sockerrno();
#endif
return rc;
}
infof(data, "Connection failed\n");
if(trynextip(conn, sockindex, connected)) {
- error = Curl_ourerrno();
+ error = Curl_sockerrno();
data->state.os_errno = error;
failf(data, "Failed connect to %s:%d; %s",
conn->host.name, conn->port, Curl_strerror(conn,error));
if(setsockopt(sockfd, proto, TCP_NODELAY, (void *)&onoff,
sizeof(onoff)) < 0)
infof(data, "Could not set TCP_NODELAY: %s\n",
- Curl_strerror(conn, Curl_ourerrno()));
+ Curl_strerror(conn, Curl_sockerrno()));
else
infof(data,"TCP_NODELAY set\n");
#else
if(setsockopt(sockfd, SOL_SOCKET, SO_NOSIGPIPE, (void *)&onoff,
sizeof(onoff)) < 0)
infof(data, "Could not set SO_NOSIGPIPE: %s\n",
- Curl_strerror(conn, Curl_ourerrno()));
+ Curl_strerror(conn, Curl_sockerrno()));
}
#else
#define nosigpipe(x,y)
rc = 0;
if(-1 == rc) {
- error = Curl_ourerrno();
+ error = Curl_sockerrno();
switch (error) {
case EINPROGRESS:
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
- * Copyright (C) 1998 - 2005, Daniel Stenberg, <daniel@haxx.se>, et al.
+ * Copyright (C) 1998 - 2006, Daniel Stenberg, <daniel@haxx.se>, et al.
*
* This software is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms
bool *connected /* truly connected? */
);
-int Curl_ourerrno(void);
+int Curl_sockerrno(void);
CURLcode Curl_store_ip_addr(struct connectdata *conn);
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
- * Copyright (C) 1998 - 2005, Daniel Stenberg, <daniel@haxx.se>, et al.
+ * Copyright (C) 1998 - 2006, Daniel Stenberg, <daniel@haxx.se>, et al.
*
* This software is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms
#include <sys/stat.h>
#endif
-#include <errno.h>
-
#if defined(WIN32) && !defined(__GNUC__) || defined(__MINGW32__)
#include <time.h>
#include <io.h>
#include <sys/stat.h>
#endif
-#include <errno.h>
-
#if defined(WIN32) && !defined(__GNUC__) || defined(__MINGW32__)
#include <time.h>
#include <io.h>
#include <stdlib.h>
#include <stdarg.h>
#include <ctype.h>
-#include <errno.h>
#ifdef HAVE_UNISTD_H
#include <unistd.h>
#endif
#endif
-#if defined(WIN32) && defined(__GNUC__) || defined(__MINGW32__)
-#include <errno.h>
-#endif
-
#if (defined(NETWARE) && defined(__NOVELL_LIBC__))
#undef in_addr_t
#define in_addr_t unsigned long
switch (Curl_select(sockfd, CURL_SOCKET_BAD, interval_ms)) {
case -1: /* select() error, stop reading */
result = CURLE_RECV_ERROR;
- failf(data, "FTP response aborted due to select() error: %d", errno);
+ failf(data, "FTP response aborted due to select() error: %d",
+ Curl_sockerrno());
break;
case 0: /* timeout */
if(Curl_pgrsUpdate(conn))
portsock = socket(ai->ai_family, ai->ai_socktype, ai->ai_protocol);
if (portsock == CURL_SOCKET_BAD) {
- error = Curl_ourerrno();
+ error = Curl_sockerrno();
continue;
}
break;
((struct sockaddr_in6 *)sa)->sin6_port =0;
if(bind(portsock, (struct sockaddr *)sa, sslen) < 0) {
- failf(data, "bind failed: %s", Curl_strerror(conn, Curl_ourerrno()));
+ failf(data, "bind failed: %s", Curl_strerror(conn, Curl_sockerrno()));
sclose(portsock);
return CURLE_FTP_PORT_FAILED;
}
sslen = sizeof(ss);
if(getsockname(portsock, (struct sockaddr *)sa, &sslen)<0) {
failf(data, "getsockname() failed: %s",
- Curl_strerror(conn, Curl_ourerrno()) );
+ Curl_strerror(conn, Curl_sockerrno()) );
return CURLE_FTP_PORT_FAILED;
}
/* step 4, listen on the socket */
if (listen(portsock, 1) < 0) {
- error = Curl_ourerrno();
+ error = Curl_sockerrno();
sclose(portsock);
failf(data, "socket failure: %s", Curl_strerror(conn, error));
return CURLE_FTP_PORT_FAILED;
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
- * Copyright (C) 1998 - 2005, Daniel Stenberg, <daniel@haxx.se>, et al.
+ * Copyright (C) 1998 - 2006, Daniel Stenberg, <daniel@haxx.se>, et al.
*
* This software is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms
#include "setup.h"
#include <string.h>
-#include <errno.h>
#ifdef HAVE_MALLOC_H /* Win32 */
#include <malloc.h>
break;
tvp = ares_timeout(data->state.areschannel, &store, &tv);
count = select(nfds, &read_fds, &write_fds, NULL, tvp);
- if (count < 0 && errno != EINVAL)
+ if (count < 0 && Curl_sockerrno() != EINVAL)
break;
ares_process(data->state.areschannel, &read_fds, &write_fds);
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
- * Copyright (C) 1998 - 2005, Daniel Stenberg, <daniel@haxx.se>, et al.
+ * Copyright (C) 1998 - 2006, Daniel Stenberg, <daniel@haxx.se>, et al.
*
* This software is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms
#include "setup.h"
#include <string.h>
-#include <errno.h>
#ifdef HAVE_MALLOC_H /* Win32 */
#include <malloc.h>
#include "setup.h"
#include <string.h>
-#include <errno.h>
#ifdef HAVE_MALLOC_H /* Win32 */
#include <malloc.h>
#include "setup.h"
#include <string.h>
-#include <errno.h>
#ifdef HAVE_MALLOC_H
#include <malloc.h>
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
- * Copyright (C) 1998 - 2005, Daniel Stenberg, <daniel@haxx.se>, et al.
+ * Copyright (C) 1998 - 2006, Daniel Stenberg, <daniel@haxx.se>, et al.
*
* This software is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms
#include "setup.h"
#include <string.h>
-#include <errno.h>
#ifdef HAVE_MALLOC_H
#include <malloc.h>
#include <sys/stat.h>
#endif
-#include <errno.h>
-
#if defined(WIN32) && !defined(__GNUC__) || defined(__MINGW32__)
#include <time.h>
#include <io.h>
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
- * Copyright (C) 1998 - 2005, Daniel Stenberg, <daniel@haxx.se>, et al.
+ * Copyright (C) 1998 - 2006, Daniel Stenberg, <daniel@haxx.se>, et al.
*
* This software is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms
#include <stdarg.h>
#include <stdlib.h>
#include <ctype.h>
-#include <errno.h>
#include "urldata.h"
#include "sendf.h"
bytes_written = (ssize_t)swrite(sockfd, mem, len);
if(-1 == bytes_written) {
- int err = Curl_ourerrno();
+ int err = Curl_sockerrno();
if(
#ifdef WSAEWOULDBLOCK
nread = sread(sockfd, buf, buffersize);
if(-1 == nread) {
- int err = Curl_ourerrno();
+ int err = Curl_sockerrno();
#ifdef WIN32
if(WSAEWOULDBLOCK == err)
#else
}
else {
/* anything that gets here is fatally bad */
- failf(data, "select on SSL socket, errno: %d", Curl_ourerrno());
+ failf(data, "select on SSL socket, errno: %d", Curl_sockerrno());
return CURLE_SSL_CONNECT_ERROR;
}
} /* while()-loop for the select() */
return 0;
case SSL_ERROR_SYSCALL:
failf(conn->data, "SSL_write() returned SYSCALL, errno = %d\n",
- Curl_ourerrno());
+ Curl_sockerrno());
return -1;
case SSL_ERROR_SSL:
/* A failure in the SSL library occurred, usually a protocol error.
sslerror = ERR_get_error();
failf(conn->data, "SSL read: %s, errno %d",
ERR_error_string(sslerror, error_buffer),
- Curl_ourerrno() );
+ Curl_sockerrno() );
return -1;
}
}
#ifdef HAVE_SYS_STAT_H
#include <sys/stat.h>
#endif
-#include <errno.h>
#if defined(WIN32)
#include <time.h>
conn->ip_addr->ai_addrlen);
if(rc) {
failf(conn->data, "bind() failed; %s\n",
- Curl_strerror(conn,Curl_ourerrno()));
+ Curl_strerror(conn, Curl_sockerrno()));
return CURLE_COULDNT_CONNECT;
}
if(rc == -1) {
/* bail out */
- int error = Curl_ourerrno();
+ int error = Curl_sockerrno();
failf(data, "%s\n", Curl_strerror(conn, error));
event = TFTP_EVENT_ERROR;
}