]> granicus.if.org Git - curl/commitdiff
TFTP: Work around tftpd-hpa upload bug
authorTim Newsome <tnewsome@aristanetworks.com>
Fri, 24 Sep 2010 16:43:49 +0000 (09:43 -0700)
committerDaniel Stenberg <daniel@haxx.se>
Sun, 26 Sep 2010 21:30:56 +0000 (23:30 +0200)
tftpd-hpa has a bug where it will send an incorrect ack when the block
counter wraps and tftp options have been sent. Work around that by
accepting an ack for 65535 when we're expecting one for 0.

lib/tftp.c

index 83be8e2b94706f18bf50f85d0c536f34b33f81d1..95da9b8934a800ad66f4874ded49065485a96a2b 100644 (file)
@@ -719,7 +719,13 @@ static CURLcode tftp_tx(tftp_state_data_t *state, tftp_event_t event)
        /* Ack the packet */
        rblock = getrpacketblock(&state->rpacket);
 
-       if(rblock != state->block) {
+       if(rblock != state->block &&
+             /* There's a bug in tftpd-hpa that causes it to send us an ack for
+              * 65535 when the block number wraps to 0. So when we're expecting
+              * 0, also accept 65535. See
+              * http://syslinux.zytor.com/archives/2010-September/015253.html
+              * */
+             !(state->block == 0 && rblock == 65535)) {
           /* This isn't the expected block.  Log it and up the retry counter */
           infof(data, "Received ACK for block %d, expecting %d\n",
                 rblock, state->block);