diff options
author | Henning Brauer <henning@cvs.openbsd.org> | 2003-04-17 17:17:28 +0000 |
---|---|---|
committer | Henning Brauer <henning@cvs.openbsd.org> | 2003-04-17 17:17:28 +0000 |
commit | 34acf235688cfc7de559db2e6da860177b087c67 (patch) | |
tree | 17b5af9f70c53c2b00e28292cf996201cf52408d /usr.bin/tftp/tftp.c | |
parent | 988b4ff4aaec196c993ecb5234a8350eda8ade72 (diff) |
nuke strcpy + -Wall
parts from and ok mickey@
Diffstat (limited to 'usr.bin/tftp/tftp.c')
-rw-r--r-- | usr.bin/tftp/tftp.c | 31 |
1 files changed, 14 insertions, 17 deletions
diff --git a/usr.bin/tftp/tftp.c b/usr.bin/tftp/tftp.c index 8809155d4cd..19b4842c873 100644 --- a/usr.bin/tftp/tftp.c +++ b/usr.bin/tftp/tftp.c @@ -1,4 +1,4 @@ -/* $OpenBSD: tftp.c,v 1.10 2002/02/16 21:27:55 millert Exp $ */ +/* $OpenBSD: tftp.c,v 1.11 2003/04/17 17:17:27 henning Exp $ */ /* $NetBSD: tftp.c,v 1.5 1995/04/29 05:55:25 cgd Exp $ */ /* @@ -38,7 +38,7 @@ #if 0 static char sccsid[] = "@(#)tftp.c 8.1 (Berkeley) 6/6/93"; #endif -static char rcsid[] = "$OpenBSD: tftp.c,v 1.10 2002/02/16 21:27:55 millert Exp $"; +static const char rcsid[] = "$OpenBSD: tftp.c,v 1.11 2003/04/17 17:17:27 henning Exp $"; #endif /* not lint */ /* Many bug fixes are from Jim Guyton <guyton@rand-unix> */ @@ -58,6 +58,7 @@ static char rcsid[] = "$OpenBSD: tftp.c,v 1.10 2002/02/16 21:27:55 millert Exp $ #include <setjmp.h> #include <signal.h> #include <stdio.h> +#include <stddef.h> #include <string.h> #include <unistd.h> #include <err.h> @@ -96,13 +97,11 @@ sendfile(fd, name, mode) char *name; char *mode; { - struct tftphdr *ap; /* data and ack packets */ - struct tftphdr *r_init(), *dp; - int n; + struct tftphdr *dp, *ap; /* data and ack packets */ volatile int block, size, convert; volatile unsigned long amount; struct sockaddr_in from; - int fromlen; + int n, fromlen; FILE *file; startclock(); /* start stat's clock */ @@ -201,13 +200,11 @@ recvfile(fd, name, mode) char *name; char *mode; { - struct tftphdr *ap; - struct tftphdr *dp, *w_init(); - int n; + struct tftphdr *dp, *ap; volatile int block, size, firsttrip; volatile unsigned long amount; struct sockaddr_in from; - int fromlen; + int n, fromlen; FILE *file; volatile int convert; /* true if converting crlf -> lf */ @@ -312,16 +309,16 @@ makerequest(request, name, tp, mode) const char *mode; { char *cp; + int len, pktlen; tp->th_opcode = htons((u_short)request); cp = tp->th_stuff; - strcpy(cp, name); - cp += strlen(name); - *cp++ = '\0'; - strcpy(cp, mode); - cp += strlen(mode); - *cp++ = '\0'; - return (cp - (char *)tp); + pktlen = PKTSIZE - offsetof(struct tftphdr, th_stuff); + len = strlen(name) + 1; + strlcpy(cp, name, pktlen); + strlcpy(cp + len, mode, pktlen - len); + len += strlen(mode) + 1; + return (cp + len - (char *)tp); } struct errmsg { |