Fix major lossage: 0.15 got based on an outdated repository!!!

This commit is contained in:
hpa 2001-03-30 01:07:52 +00:00
parent d0fec7a322
commit 0ba1a99f5d
2 changed files with 23 additions and 13 deletions

View file

@ -34,7 +34,7 @@
.\" from: @(#)tftpd.8 6.7 (Berkeley) 5/13/91 .\" from: @(#)tftpd.8 6.7 (Berkeley) 5/13/91
.\" $OpenBSD: tftpd.8,v 1.7 1999/07/09 13:35:51 aaron Exp $ .\" $OpenBSD: tftpd.8,v 1.7 1999/07/09 13:35:51 aaron Exp $
.\" .\"
.Dd June 11, 1997 .Dd July 9, 2000
.Dt TFTPD 8 .Dt TFTPD 8
.Os .Os
.Sh NAME .Sh NAME
@ -111,7 +111,7 @@ This version of
supports RFC 2347 option negotiation; the current version supports the supports RFC 2347 option negotiation; the current version supports the
.Pa blksize .Pa blksize
(RFC 2348), (RFC 2348),
.Pa blksize , .Pa tsize ,
(RFC 2349), and (RFC 2349), and
.Pa timeout .Pa timeout
(RFC 2349) options. The (RFC 2349) options. The

View file

@ -75,6 +75,14 @@ static const char *rcsid = "tftp-hpa $Id$";
#include "tftpsubs.h" #include "tftpsubs.h"
#include "recvfrom.h" #include "recvfrom.h"
void bsd_signal(int, void (*)(int));
#ifndef HAVE_SIGSETJMP
#define sigsetjmp(x,y) setjmp(x)
#define siglongjmp(x,y) longjmp(x,y)
#define sigjmp_buf jmp_buf
#endif
#define TIMEOUT 5 /* Default timeout (seconds) */ #define TIMEOUT 5 /* Default timeout (seconds) */
#define TRIES 4 /* Number of attempts to send each packet */ #define TRIES 4 /* Number of attempts to send each packet */
#define TIMEOUT_LIMIT (TRIES*(TRIES+1)/2) #define TIMEOUT_LIMIT (TRIES*(TRIES+1)/2)
@ -86,8 +94,8 @@ static const char *rcsid = "tftp-hpa $Id$";
#define EOPTNEG 8 #define EOPTNEG 8
#endif #endif
extern int errno;
extern char *__progname; extern char *__progname;
struct sockaddr_in s_in;
int peer; int peer;
int timeout = TIMEOUT; int timeout = TIMEOUT;
int rexmtval = TIMEOUT; int rexmtval = TIMEOUT;
@ -147,7 +155,6 @@ main(int argc, char **argv)
struct tftphdr *tp; struct tftphdr *tp;
struct passwd *pw; struct passwd *pw;
struct options *opt; struct options *opt;
struct sockaddr_in myaddr;
int n = 0; int n = 0;
int on = 1; int on = 1;
int fd = 0; int fd = 0;
@ -625,7 +632,7 @@ validate_access(char *filename, int mode, struct formats *pf)
} }
int timeout; int timeout;
jmp_buf timeoutbuf; sigjmp_buf timeoutbuf;
void void
timer(int sig) timer(int sig)
@ -634,7 +641,7 @@ timer(int sig)
timeout += rexmtval; timeout += rexmtval;
if (timeout >= maxtimeout) if (timeout >= maxtimeout)
exit(0); exit(0);
longjmp(timeoutbuf, 1); siglongjmp(timeoutbuf, 1);
} }
/* /*
@ -647,18 +654,18 @@ sendfile(struct formats *pf, struct tftphdr *oap, int oacklen)
struct tftphdr *ap; /* ack packet */ struct tftphdr *ap; /* ack packet */
int block = 1, size, n; int block = 1, size, n;
signal(SIGALRM, timer);
ap = (struct tftphdr *)ackbuf; ap = (struct tftphdr *)ackbuf;
if (oap) { if (oap) {
timeout = 0; timeout = 0;
(void)setjmp(timeoutbuf); (void)sigsetjmp(timeoutbuf,1);
oack: oack:
if (send(peer, oap, oacklen, 0) != oacklen) { if (send(peer, oap, oacklen, 0) != oacklen) {
syslog(LOG_ERR, "tftpd: oack: %m\n"); syslog(LOG_ERR, "tftpd: oack: %m\n");
goto abort; goto abort;
} }
for ( ; ; ) { for ( ; ; ) {
bsd_signal(SIGALRM, timer);
alarm(rexmtval); alarm(rexmtval);
n = recv(peer, ackbuf, sizeof(ackbuf), 0); n = recv(peer, ackbuf, sizeof(ackbuf), 0);
alarm(0); alarm(0);
@ -694,7 +701,7 @@ oack:
dp->th_opcode = htons((u_short)DATA); dp->th_opcode = htons((u_short)DATA);
dp->th_block = htons((u_short)block); dp->th_block = htons((u_short)block);
timeout = 0; timeout = 0;
(void) setjmp(timeoutbuf); (void) sigsetjmp(timeoutbuf,1);
send_data: send_data:
if (send(peer, dp, size + 4, 0) != size + 4) { if (send(peer, dp, size + 4, 0) != size + 4) {
@ -703,6 +710,7 @@ send_data:
} }
read_ahead(file, pf->f_convert); read_ahead(file, pf->f_convert);
for ( ; ; ) { for ( ; ; ) {
bsd_signal(SIGALRM, timer);
alarm(rexmtval); /* read the ack */ alarm(rexmtval); /* read the ack */
n = recv(peer, ackbuf, sizeof (ackbuf), 0); n = recv(peer, ackbuf, sizeof (ackbuf), 0);
alarm(0); alarm(0);
@ -751,12 +759,11 @@ recvfile(struct formats *pf, struct tftphdr *oap, int oacklen)
struct tftphdr *ap; /* ack buffer */ struct tftphdr *ap; /* ack buffer */
int block = 0, acksize, n, size; int block = 0, acksize, n, size;
signal(SIGALRM, timer);
dp = w_init(); dp = w_init();
do { do {
timeout = 0; timeout = 0;
if (!block++ && oap) { if (!block && oap) {
ap = (struct tftphdr *)ackbuf; ap = (struct tftphdr *)ackbuf;
acksize = oacklen; acksize = oacklen;
} else { } else {
@ -765,7 +772,9 @@ recvfile(struct formats *pf, struct tftphdr *oap, int oacklen)
ap->th_block = htons((u_short)block); ap->th_block = htons((u_short)block);
acksize = 4; acksize = 4;
} }
(void) setjmp(timeoutbuf); block++;
(void) sigsetjmp(timeoutbuf,1);
bsd_signal(SIGALRM, timer);
send_ack: send_ack:
if (send(peer, ackbuf, acksize, 0) != acksize) { if (send(peer, ackbuf, acksize, 0) != acksize) {
syslog(LOG_ERR, "tftpd: write(ack): %m"); syslog(LOG_ERR, "tftpd: write(ack): %m");
@ -773,6 +782,7 @@ send_ack:
} }
write_behind(file, pf->f_convert); write_behind(file, pf->f_convert);
for ( ; ; ) { for ( ; ; ) {
bsd_signal(SIGALRM, timer);
alarm(rexmtval); alarm(rexmtval);
n = recv(peer, dp, PKTSIZE, 0); n = recv(peer, dp, PKTSIZE, 0);
alarm(0); alarm(0);
@ -809,7 +819,7 @@ send_ack:
ap->th_block = htons((u_short)(block)); ap->th_block = htons((u_short)(block));
(void) send(peer, ackbuf, 4, 0); (void) send(peer, ackbuf, 4, 0);
signal(SIGALRM, justquit); /* just quit on timeout */ bsd_signal(SIGALRM, justquit); /* just quit on timeout */
alarm(rexmtval); alarm(rexmtval);
n = recv(peer, buf, sizeof (buf), 0); /* normally times out and quits */ n = recv(peer, buf, sizeof (buf), 0); /* normally times out and quits */
alarm(0); alarm(0);