curl-library
getsockname fails due to size_t
Date: Fri, 22 Dec 2006 01:16:35 +0000
The getsockname call in connect.c uses size_t instead of socklen_t.
This breaks if a platform's size_t isn't the same size as socklen_t, causing
the getsockname to fail.
My patch (attached and below) uses socklen_t and removes the
no-longer-necessary casting.
-David
--- curl-7.16.1-20061221/lib/connect.c 2006-10-18 22:00:25.000000000 -0400
+++ curlinux/lib/connect.c 2006-12-21 19:32:22.050719000 -0500
@@ -384,11 +384,10 @@
if( bind(sockfd, sock, socksize) >= 0) {
/* we succeeded to bind */
struct Curl_sockaddr_storage add;
- size_t size;
+ socklen_t size;
size = sizeof(add);
- if(getsockname(sockfd, (struct sockaddr *) &add,
- (socklen_t *)&size)<0) {
+ if(getsockname(sockfd, (struct sockaddr *) &add, &size)<0) {
failf(data, "getsockname() failed");
return CURLE_HTTP_PORT_FAILED;
}
- text/plain attachment: connect_socklen_t_patch.txt