From 316f1206014cd3c2921eff1e1c621c97599cd644 Mon Sep 17 00:00:00 2001 From: dwmalone Date: Wed, 27 Feb 2002 15:22:12 +0000 Subject: 1) Move FreeBSD ID below vendor ID and don't compile vendor ID. 2) Cast some numbers we know to be positive to size_t before we MIN them with the result of a sizeof. 3) Compare result of inet_addr to INADDR_NONE, not -1. --- usr.bin/tftp/main.c | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) (limited to 'usr.bin/tftp/main.c') diff --git a/usr.bin/tftp/main.c b/usr.bin/tftp/main.c index a607606..2d29321 100644 --- a/usr.bin/tftp/main.c +++ b/usr.bin/tftp/main.c @@ -31,19 +31,20 @@ * SUCH DAMAGE. */ -#include - -__FBSDID("$FreeBSD$"); - #ifndef lint static const char copyright[] = "@(#) Copyright (c) 1983, 1993\n\ The Regents of the University of California. All rights reserved.\n"; #endif +#if 0 #ifndef lint -static const char sccsid[] = "@(#)main.c 8.1 (Berkeley) 6/6/93"; +static char sccsid[] = "@(#)main.c 8.1 (Berkeley) 6/6/93"; #endif +#endif + +#include +__FBSDID("$FreeBSD$"); /* Many bug fixes are from Jim Guyton */ @@ -208,12 +209,12 @@ setpeer(argc, argv) if (host) { peeraddr.sin_family = host->h_addrtype; bcopy(host->h_addr, &peeraddr.sin_addr, - MIN(sizeof(peeraddr.sin_addr), host->h_length)); + MIN(sizeof(peeraddr.sin_addr), (size_t)host->h_length)); strncpy(hostname, host->h_name, sizeof(hostname)); } else { peeraddr.sin_family = AF_INET; peeraddr.sin_addr.s_addr = inet_addr(argv[1]); - if (peeraddr.sin_addr.s_addr == -1) { + if (peeraddr.sin_addr.s_addr == INADDR_NONE) { connected = 0; printf("%s: unknown host\n", argv[1]); return; @@ -354,7 +355,7 @@ put(argc, argv) return; } bcopy(hp->h_addr, (caddr_t)&peeraddr.sin_addr, - MIN(sizeof(peeraddr.sin_addr), hp->h_length)); + MIN(sizeof(peeraddr.sin_addr), (size_t)hp->h_length)); peeraddr.sin_family = hp->h_addrtype; connected = 1; strncpy(hostname, hp->h_name, sizeof(hostname)); @@ -452,7 +453,7 @@ get(argc, argv) continue; } bcopy(hp->h_addr, (caddr_t)&peeraddr.sin_addr, - MIN(sizeof(peeraddr.sin_addr), hp->h_length)); + MIN(sizeof(peeraddr.sin_addr), (size_t)hp->h_length)); peeraddr.sin_family = hp->h_addrtype; connected = 1; strncpy(hostname, hp->h_name, sizeof(hostname)); -- cgit v1.1