From a58b9604c52694b252c73fffe5de951b0f821ea9 Mon Sep 17 00:00:00 2001 From: hpa Date: Tue, 13 Nov 2001 03:39:32 +0000 Subject: [PATCH] Even more changes to handle block number wrap correctly. Make the client officially supported. It's better than most things that are already out there. --- CHANGES | 2 ++ README | 5 ----- tftp/tftp.c | 11 +++++++---- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/CHANGES b/CHANGES index 3478559..2ae9114 100644 --- a/CHANGES +++ b/CHANGES @@ -5,6 +5,8 @@ Changes in 0.24: wraparound, usually manifesting themselves as failure to handle files over 32 MB in size. + Officially make the client a part of the tftp-hpa project. + Changes in 0.23: Correct memory overwrite bug in the tftp client when compiled diff --git a/README b/README index f57efe1..fc25395 100644 --- a/README +++ b/README @@ -23,8 +23,3 @@ installation instructions. This software can be discussed on the SYSLINUX mailing list. To subscribe, send a message containing the word "subscribe" in the body to . - -Please note that my main focus in this work is the tftpd -server. Although a tftp client is included, it is by and large the -stock OpenBSD version, with a small handful of portability -improvements. diff --git a/tftp/tftp.c b/tftp/tftp.c index 279527b..fe8a88d 100644 --- a/tftp/tftp.c +++ b/tftp/tftp.c @@ -104,9 +104,10 @@ tftp_sendfile(int fd, char *name, char *mode) struct tftphdr *ap; /* data and ack packets */ struct tftphdr *dp; int n; + volatile int is_request; volatile u_short block; volatile int size, convert; - volatile unsigned long amount; + volatile off_t amount; struct sockaddr_in from; int fromlen; FILE *file; @@ -117,13 +118,14 @@ tftp_sendfile(int fd, char *name, char *mode) file = fdopen(fd, "r"); convert = !strcmp(mode, "netascii"); block = 0; + is_request = 1; /* First packet is the actual WRQ */ amount = 0; bsd_signal(SIGALRM, timer); do { - if (block == 0) + if (is_request) { size = makerequest(WRQ, name, dp, mode) - 4; - else { + } else { /* size = read(fd, dp->th_data, SEGSIZE); */ size = readit(file, &dp, convert); if (size < 0) { @@ -187,8 +189,9 @@ send_data: } } } - if (block > 0) + if ( !is_request ) amount += size; + is_request = 0; block++; } while (size == SEGSIZE || block == 1); abort: