diff options
Diffstat (limited to 'contrib/amd/fixmount/fixmount.c')
-rw-r--r-- | contrib/amd/fixmount/fixmount.c | 28 |
1 files changed, 12 insertions, 16 deletions
diff --git a/contrib/amd/fixmount/fixmount.c b/contrib/amd/fixmount/fixmount.c index 058c30f..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,9 +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 $ + * File: am-utils/fixmount/fixmount.c * */ @@ -50,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 @@ -120,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); } @@ -164,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); @@ -326,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 '?': @@ -367,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; } @@ -497,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; @@ -568,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, |