forked from mirrors/tftp-hpa-google
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.
This commit is contained in:
parent
480bee14e9
commit
a58b9604c5
3 changed files with 9 additions and 9 deletions
2
CHANGES
2
CHANGES
|
@ -5,6 +5,8 @@ Changes in 0.24:
|
||||||
wraparound, usually manifesting themselves as failure to
|
wraparound, usually manifesting themselves as failure to
|
||||||
handle files over 32 MB in size.
|
handle files over 32 MB in size.
|
||||||
|
|
||||||
|
Officially make the client a part of the tftp-hpa project.
|
||||||
|
|
||||||
|
|
||||||
Changes in 0.23:
|
Changes in 0.23:
|
||||||
Correct memory overwrite bug in the tftp client when compiled
|
Correct memory overwrite bug in the tftp client when compiled
|
||||||
|
|
5
README
5
README
|
@ -23,8 +23,3 @@ installation instructions.
|
||||||
This software can be discussed on the SYSLINUX mailing list. To
|
This software can be discussed on the SYSLINUX mailing list. To
|
||||||
subscribe, send a message containing the word "subscribe" in the body
|
subscribe, send a message containing the word "subscribe" in the body
|
||||||
to <syslinux-request@linux.kernel.org>.
|
to <syslinux-request@linux.kernel.org>.
|
||||||
|
|
||||||
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.
|
|
||||||
|
|
11
tftp/tftp.c
11
tftp/tftp.c
|
@ -104,9 +104,10 @@ tftp_sendfile(int fd, char *name, char *mode)
|
||||||
struct tftphdr *ap; /* data and ack packets */
|
struct tftphdr *ap; /* data and ack packets */
|
||||||
struct tftphdr *dp;
|
struct tftphdr *dp;
|
||||||
int n;
|
int n;
|
||||||
|
volatile int is_request;
|
||||||
volatile u_short block;
|
volatile u_short block;
|
||||||
volatile int size, convert;
|
volatile int size, convert;
|
||||||
volatile unsigned long amount;
|
volatile off_t amount;
|
||||||
struct sockaddr_in from;
|
struct sockaddr_in from;
|
||||||
int fromlen;
|
int fromlen;
|
||||||
FILE *file;
|
FILE *file;
|
||||||
|
@ -117,13 +118,14 @@ tftp_sendfile(int fd, char *name, char *mode)
|
||||||
file = fdopen(fd, "r");
|
file = fdopen(fd, "r");
|
||||||
convert = !strcmp(mode, "netascii");
|
convert = !strcmp(mode, "netascii");
|
||||||
block = 0;
|
block = 0;
|
||||||
|
is_request = 1; /* First packet is the actual WRQ */
|
||||||
amount = 0;
|
amount = 0;
|
||||||
|
|
||||||
bsd_signal(SIGALRM, timer);
|
bsd_signal(SIGALRM, timer);
|
||||||
do {
|
do {
|
||||||
if (block == 0)
|
if (is_request) {
|
||||||
size = makerequest(WRQ, name, dp, mode) - 4;
|
size = makerequest(WRQ, name, dp, mode) - 4;
|
||||||
else {
|
} else {
|
||||||
/* size = read(fd, dp->th_data, SEGSIZE); */
|
/* size = read(fd, dp->th_data, SEGSIZE); */
|
||||||
size = readit(file, &dp, convert);
|
size = readit(file, &dp, convert);
|
||||||
if (size < 0) {
|
if (size < 0) {
|
||||||
|
@ -187,8 +189,9 @@ send_data:
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (block > 0)
|
if ( !is_request )
|
||||||
amount += size;
|
amount += size;
|
||||||
|
is_request = 0;
|
||||||
block++;
|
block++;
|
||||||
} while (size == SEGSIZE || block == 1);
|
} while (size == SEGSIZE || block == 1);
|
||||||
abort:
|
abort:
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue