From a63534e6e6fa351d1c51b1d7cd14f916af3f835a Mon Sep 17 00:00:00 2001 From: "H. Peter Anvin" Date: Fri, 11 Dec 2009 16:05:48 -0800 Subject: [PATCH 1/3] recvfrom: fix the type of the fallthrough case If we can't figure out the source address, we have the "fall on our face" version of myrecvfrom(); make sure its prototype matches. This handles building on machines where sockaddr_t != int and yet there is no way to get the source address. This apparently affects at least one version of Solaris. Reported-by: Georg Schwarz Signed-off-by: H. Peter Anvin --- tftpd/recvfrom.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tftpd/recvfrom.c b/tftpd/recvfrom.c index 389ba82..3ee5642 100644 --- a/tftpd/recvfrom.c +++ b/tftpd/recvfrom.c @@ -245,7 +245,8 @@ myrecvfrom(int s, void *buf, int len, unsigned int flags, int myrecvfrom(int s, void *buf, int len, unsigned int flags, - struct sockaddr *from, int *fromlen, union sock_addr *myaddr) + struct sockaddr *from, socklen_t * fromlen, + union sock_addr *myaddr) { /* There is no way we can get the local address, fudge it */ From aeb1c31bae431ad3b9269befa221229458adb854 Mon Sep 17 00:00:00 2001 From: Tim Newsome Date: Wed, 8 Sep 2010 14:11:42 -0700 Subject: [PATCH 2/3] tftpd: Don't resend the OACK packet on block number wrap When uploading a file that is larger than 32MB (with standard block size), the block number will roll over. If it rolls over to 0, the code mistakenly resends the option ack frame instead of acknowledging the 0 data block. This change fixes that behavior. --- tftpd/tftpd.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/tftpd/tftpd.c b/tftpd/tftpd.c index 69ff121..0a8da72 100644 --- a/tftpd/tftpd.c +++ b/tftpd/tftpd.c @@ -1646,6 +1646,10 @@ static void tftp_recvfile(struct formats *pf, struct tftphdr *oap, int oacklen) ap->th_opcode = htons((u_short) ACK); ap->th_block = htons((u_short) block); acksize = 4; + /* If we're sending a regular ACK, that means we have successfully + * sent the OACK. Clear oap so that we won't try to send another + * OACK when the block number wraps back to 0. */ + oap = NULL; } if (!++block) block = rollover_val; From 915f62f5c76d7bd953b758d477b542acf6a3bf65 Mon Sep 17 00:00:00 2001 From: "H. Peter Anvin" Date: Mon, 20 Sep 2010 17:49:10 -0700 Subject: [PATCH 3/3] CHANGES: document wraparound fix --- CHANGES | 3 +++ 1 file changed, 3 insertions(+) diff --git a/CHANGES b/CHANGES index cdb9a2e..5238089 100644 --- a/CHANGES +++ b/CHANGES @@ -6,6 +6,9 @@ Changes in 5.1: Build fixes. + Fix handling of block number wraparound after a successful + options negotiation. + Changes in 5.0: Try to on platforms with getaddrinfo() without AI_ADDRCONFIG or