summaryrefslogtreecommitdiffstats
path: root/contrib/amd/fixmount
diff options
context:
space:
mode:
authorobrien <obrien@FreeBSD.org>2007-12-05 16:57:05 +0000
committerobrien <obrien@FreeBSD.org>2007-12-05 16:57:05 +0000
commit4487f06b05a86d08708b1e443a0376c53b8e82c0 (patch)
treee7b85ce620ca0374e09e7d585e7a5276830543ab /contrib/amd/fixmount
parent0e36aeab452c052d7082c42ba10cb6382ea80e16 (diff)
downloadFreeBSD-src-4487f06b05a86d08708b1e443a0376c53b8e82c0.zip
FreeBSD-src-4487f06b05a86d08708b1e443a0376c53b8e82c0.tar.gz
Put stock 6.1.5 file into HEAD.
Diffstat (limited to 'contrib/amd/fixmount')
-rw-r--r--contrib/amd/fixmount/fixmount.c29
1 files changed, 12 insertions, 17 deletions
diff --git a/contrib/amd/fixmount/fixmount.c b/contrib/amd/fixmount/fixmount.c
index 3e00786..c7c6910 100644
--- a/contrib/amd/fixmount/fixmount.c
+++ b/contrib/amd/fixmount/fixmount.c
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1997-2004 Erez Zadok
+ * Copyright (c) 1997-2006 Erez Zadok
* Copyright (c) 1990 Jan-Simon Pendry
* Copyright (c) 1990 Imperial College of Science, Technology & Medicine
* Copyright (c) 1990 The Regents of the University of California.
@@ -36,10 +36,8 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * %W% (Berkeley) %G%
*
- * $Id: fixmount.c,v 1.5.2.4 2004/01/06 03:15:23 ezk Exp $
- * $FreeBSD$
+ * File: am-utils/fixmount/fixmount.c
*
*/
@@ -51,10 +49,6 @@
#define CREATE_TIMEOUT 2 /* seconds */
#define CALL_TIMEOUT 5 /* seconds */
-#ifndef INADDR_NONE
-# define INADDR_NONE 0xffffffff
-#endif /* not INADDR_NONE */
-
/* Constant defs */
#define ALL 1
#define DIRS 2
@@ -121,7 +115,7 @@ is_same_host(char *name1, char *name2, struct in_addr addr2)
} else if (!(he = gethostbyname(name1))) {
return 0;
} else {
- strncpy(lasthost, name1, sizeof(lasthost) - 1);
+ xstrlcpy(lasthost, name1, MAXHOSTNAMELEN);
memcpy(&addr1, he->h_addr, sizeof(addr1));
return (addr1.s_addr == addr2.s_addr);
}
@@ -165,7 +159,7 @@ remove_mount(CLIENT *client, char *host, mountlist ml, int fixit)
struct timeval tv;
char *pathp = dir_path;
- strncpy(dir_path, ml->ml_directory, sizeof(dir_path));
+ xstrlcpy(dir_path, ml->ml_directory, sizeof(dir_path));
if (!fixit) {
printf("%s: bogus mount %s:%s\n", host, ml->ml_hostname, ml->ml_directory);
@@ -327,8 +321,7 @@ main(int argc, char *argv[])
break;
case 'h':
- strncpy(thishost, optarg, sizeof(thishost));
- thishost[sizeof(thishost) - 1] = '\0';
+ xstrlcpy(thishost, optarg, sizeof(thishost));
break;
case '?':
@@ -368,8 +361,7 @@ main(int argc, char *argv[])
inet_ntoa(thisaddr));
exit(1);
}
- strncpy(thishost, he->h_name, sizeof(thishost));
- thishost[sizeof(thishost) - 1] = '\0';
+ xstrlcpy(thishost, he->h_name, sizeof(thishost));
} else {
thisaddr.s_addr = INADDR_NONE;
}
@@ -498,8 +490,10 @@ inetresport(int ty)
struct sockaddr_in addr;
int fd;
- /* Use internet address family */
- addr.sin_family = AF_INET;
+ memset(&addr, 0, sizeof(addr));
+ /* as per POSIX, sin_len need not be set (used internally by kernel) */
+
+ addr.sin_family = AF_INET; /* use internet address family */
addr.sin_addr.s_addr = INADDR_ANY;
if ((fd = socket(AF_INET, ty, 0)) < 0)
return -1;
@@ -569,7 +563,8 @@ clnt_create_timeout(char *host, struct timeval *tvp)
fprintf(stderr, "can't get address of %s\n", host);
return NULL;
}
- memset(&host_addr, 0, sizeof host_addr);
+ memset(&host_addr, 0, sizeof(host_addr));
+ /* as per POSIX, sin_len need not be set (used internally by kernel) */
host_addr.sin_family = AF_INET;
if (hp) {
memmove((voidp) &host_addr.sin_addr, (voidp) hp->h_addr,
OpenPOWER on IntegriCloud