diff options
| author | Alan Somers <asomers@FreeBSD.org> | 2018-10-01 16:09:20 +0000 |
|---|---|---|
| committer | Alan Somers <asomers@FreeBSD.org> | 2018-10-01 16:09:20 +0000 |
| commit | 0f843eba705262256a114818ec5dc2f0529398e9 (patch) | |
| tree | 48f601f4edb61f53183060fd8c953efb8d98c2f5 /usr.bin | |
| parent | dc6061b1fc55d388d38c243ff6ad1f9b80887ac0 (diff) | |
Notes
Diffstat (limited to 'usr.bin')
| -rw-r--r-- | usr.bin/tftp/main.c | 12 | ||||
| -rw-r--r-- | usr.bin/tftp/tftp.c | 3 |
2 files changed, 12 insertions, 3 deletions
diff --git a/usr.bin/tftp/main.c b/usr.bin/tftp/main.c index 49bd62a4a97e..b1b24643dcc1 100644 --- a/usr.bin/tftp/main.c +++ b/usr.bin/tftp/main.c @@ -405,7 +405,7 @@ static void settftpmode(const char *newmode) { - strcpy(mode, newmode); + strlcpy(mode, newmode, sizeof(mode)); if (verbose) printf("mode set to %s\n", mode); } @@ -465,7 +465,10 @@ put(int argc, char *argv[]) return; } - stat(cp, &sb); + if (fstat(fd, &sb) < 0) { + warn("%s", cp); + return; + } asprintf(&options[OPT_TSIZE].o_request, "%ju", sb.st_size); if (verbose) @@ -486,7 +489,10 @@ put(int argc, char *argv[]) continue; } - stat(cp, &sb); + if (fstat(fd, &sb) < 0) { + warn("%s", argv[n]); + continue; + } asprintf(&options[OPT_TSIZE].o_request, "%ju", sb.st_size); if (verbose) diff --git a/usr.bin/tftp/tftp.c b/usr.bin/tftp/tftp.c index 6514af3d2a0b..ad218915689c 100644 --- a/usr.bin/tftp/tftp.c +++ b/usr.bin/tftp/tftp.c @@ -48,6 +48,7 @@ __FBSDID("$FreeBSD$"); #include <arpa/tftp.h> +#include <assert.h> #include <err.h> #include <netdb.h> #include <stdio.h> @@ -83,6 +84,7 @@ xmitfile(int peer, char *port, int fd, char *name, char *mode) if (port == NULL) { struct servent *se; se = getservbyname("tftp", "udp"); + assert(se != NULL); ((struct sockaddr_in *)&peer_sock)->sin_port = se->s_port; } else ((struct sockaddr_in *)&peer_sock)->sin_port = @@ -182,6 +184,7 @@ recvfile(int peer, char *port, int fd, char *name, char *mode) if (port == NULL) { struct servent *se; se = getservbyname("tftp", "udp"); + assert(se != NULL); ((struct sockaddr_in *)&peer_sock)->sin_port = se->s_port; } else ((struct sockaddr_in *)&peer_sock)->sin_port = |
