Re: [PATCH] Fix for tftp
Date: Fri, 24 Mar 2006 12:02:37 +0100
On Mar 23, 23:51, Daniel Stenberg wrote:
>On Thu, 23 Mar 2006, Tor Arntsen wrote:
>> The following patch fixes the bind() problem on Unix (tested on IRIX, AIX
>> and Tru64) so that tftp works.
>> - sizeof(state->local_addr));
>> + sizeof(struct sockaddr_in));
>Thanks a lot for your work and fix!
>I'm curious on why this is needed. Isn't sizeof(state->local_addr) in fact a
>good deal larger than sizeof(struct sockaddr_in) on these systems? The
>local_addr is a Curl_sockaddr_storage struct, which is declared by magic in
I tested this with a standalone program (basically a slightly modified version
of the udp client test program from Stevens) on AIX, IRIX, Tru64, Solaris 2.8
and Linux. bind() failed on all execpt Linux unless the third parameter of
bind() was exactly 16, which is the size of struct sockaddr_in on these
platforms (including Linux). Any other size just fails, except on Linux.
Sizeof local_addr is 128, but that size fails just as 15, 17, 32 and any other.
>The downside with this suggested patch is that it breaks TFTP over IPv6, and
>hence I'd like to lift a few more stones to see if we can get the bugs to
>crawl away using another method.
Maybe the follwing patch. I can't test it on IPV6 (mostly because I'm not
sure how exactly to set up an ipv6 network :-), but it works on ipv4 on
the platforms I tested (Tru64, AIX and IRIX) and looks like it at least
has the potential to do the right thing:
RCS file: /cvsroot/curl/curl/lib/tftp.c,v
retrieving revision 1.18
diff -u -p -r1.18 tftp.c
--- lib/tftp.c 20 Mar 2006 22:15:22 -0000 1.18
+++ lib/tftp.c 24 Mar 2006 10:46:25 -0000
@@ -566,7 +566,7 @@ CURLcode Curl_tftp_connect(struct connec
/* Bind to any interface, random UDP port */
rc = bind(state->sockfd, (struct sockaddr *)&state->local_addr,
failf(conn->data, "bind() failed; %s\n",
Received on 2006-03-24