From 82c992f63212a9fd0a013548e3a10a5321196772 Mon Sep 17 00:00:00 2001 From: Erez Zadok Date: Thu, 6 Oct 2005 20:18:15 +0000 Subject: [PATCH] * include/am_compat.h (INADDR_NONE): define in a common location, if OS doesn't have it, use 0xffffffffU which should work with any ANSI compiler. * fixmount/fixmount.c, libamu/wire.c: remove local definition of INADDR_NONE. * amd/amfs_toplvl.c (amfs_toplvl_mount), amd/amfs_auto.c (amfs_auto_mount): use common SIZEOF_OPTS in definition and call to autofs_get_opts. * amd/amd.h (SIZEOF_OPTS): moved #define to common header. * amd/opts.c (expand_op): Need to check BUFSPACE for env for vlen+1. Likewise for cp and strlen(cp)+1. * amd/amfs_toplvl.c (amfs_toplvl_mount) [HAVE_FS_AUTOFS]: Pass new size argument to autofs_get_opts. --- ChangeLog | 23 +++++++++++++++++++++++ amd/amd.h | 1 + amd/amfs_auto.c | 4 ++-- amd/amfs_toplvl.c | 3 +-- amd/opts.c | 11 ++++++----- fixmount/fixmount.c | 4 ---- include/am_compat.h | 5 +++++ libamu/wire.c | 4 ---- 8 files changed, 38 insertions(+), 17 deletions(-) diff --git a/ChangeLog b/ChangeLog index 2a0f122a..2361ad5f 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,26 @@ +2005-10-06 Erez Zadok + + * include/am_compat.h (INADDR_NONE): define in a common location, + if OS doesn't have it, use 0xffffffffU which should work with any + ANSI compiler. + + * fixmount/fixmount.c, libamu/wire.c: remove local definition of + INADDR_NONE. + + * amd/amfs_toplvl.c (amfs_toplvl_mount), amd/amfs_auto.c + (amfs_auto_mount): use common SIZEOF_OPTS in definition and call + to autofs_get_opts. + + * amd/amd.h (SIZEOF_OPTS): moved #define to common header. + +2005-10-06 Rainer Orth + + * amd/opts.c (expand_op): Need to check BUFSPACE for env for + vlen+1. Likewise for cp and strlen(cp)+1. + + * amd/amfs_toplvl.c (amfs_toplvl_mount) [HAVE_FS_AUTOFS]: Pass new + size argument to autofs_get_opts. + 2005-10-05 Erez Zadok * amq/pawd.c (transform_dir): use TCP first, else UDP. Destroy diff --git a/amd/amd.h b/amd/amd.h index a950a3cc..b4c70f9d 100644 --- a/amd/amd.h +++ b/amd/amd.h @@ -628,6 +628,7 @@ extern void wakeup_task(int, int, wchan_t); extern char pid_fsname[SIZEOF_PID_FSNAME]; /* "kiska.southseas.nz:(pid%d)" */ #define SIZEOF_HOSTD (2 * MAXHOSTNAMELEN + 1) extern char hostd[SIZEOF_HOSTD]; /* Host+domain */ +#define SIZEOF_OPTS 256 /* used for char opts[] and preopts[] */ /* * Global variables. diff --git a/amd/amfs_auto.c b/amd/amfs_auto.c index edf20673..3589cbd0 100644 --- a/amd/amfs_auto.c +++ b/amd/amfs_auto.c @@ -152,10 +152,10 @@ amfs_auto_mount(am_node *mp, mntfs *mf) #ifdef HAVE_FS_AUTOFS if (mf->mf_flags & MFF_IS_AUTOFS) { - char opts[256]; + char opts[SIZEOF_OPTS]; int error; - autofs_get_opts(opts, sizeof(opts), mp->am_autofs_fh); + autofs_get_opts(opts, SIZEOF_OPTS, mp->am_autofs_fh); /* now do the mount */ error = amfs_mount(mp, mf, opts); diff --git a/amd/amfs_toplvl.c b/amd/amfs_toplvl.c index 197e0fbe..0ad29575 100644 --- a/amd/amfs_toplvl.c +++ b/amd/amfs_toplvl.c @@ -170,7 +170,6 @@ int amfs_toplvl_mount(am_node *mp, mntfs *mf) { struct stat stb; -#define SIZEOF_OPTS 256 char opts[SIZEOF_OPTS], preopts[SIZEOF_OPTS]; int error; @@ -196,7 +195,7 @@ amfs_toplvl_mount(am_node *mp, mntfs *mf) #ifdef HAVE_FS_AUTOFS if (mf->mf_flags & MFF_IS_AUTOFS) { - autofs_get_opts(opts, mp->am_autofs_fh); + autofs_get_opts(opts, SIZEOF_OPTS, mp->am_autofs_fh); } else #endif /* HAVE_FS_AUTOFS */ { diff --git a/amd/opts.c b/amd/opts.c index b134490b..6773e700 100644 --- a/amd/opts.c +++ b/amd/opts.c @@ -1248,8 +1248,8 @@ expand_op(char *opt, int sel_p) if (env) { int vlen = strlen(env); - if (BUFSPACE(ep, vlen)) { - xstrlcpy(ep, env, vlen); + if (BUFSPACE(ep, vlen+1)) { + xstrlcpy(ep, env, vlen+1); ep += vlen; } else { plog(XLOG_ERROR, EXPAND_ERROR, opt); @@ -1279,9 +1279,10 @@ out: /* * Finish off the expansion */ - if (BUFSPACE(ep, strlen(cp))) { - xstrlcpy(ep, cp, strlen(cp)); - /* ep += strlen(ep); */ + int vlen = strlen(cp); + if (BUFSPACE(ep, vlen+1)) { + xstrlcpy(ep, cp, vlen+1); + /* ep += vlen; */ } else { plog(XLOG_ERROR, EXPAND_ERROR, opt); } diff --git a/fixmount/fixmount.c b/fixmount/fixmount.c index 47ee11b9..376d8c14 100644 --- a/fixmount/fixmount.c +++ b/fixmount/fixmount.c @@ -49,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 diff --git a/include/am_compat.h b/include/am_compat.h index 79453296..a430e162 100644 --- a/include/am_compat.h +++ b/include/am_compat.h @@ -355,4 +355,9 @@ struct netconfig { }; #endif /* not HAVE_NETCONFIG_H and not HAVE_SYS_NETCONFIG_H */ +/* some OSs don't define INADDR_NONE and assume it's unsigned -1 */ +#ifndef INADDR_NONE +# define INADDR_NONE 0xffffffffU +#endif /* INADDR_NONE */ + #endif /* not _AM_COMPAT_H */ diff --git a/libamu/wire.c b/libamu/wire.c index 827a5b22..2a1c44cf 100644 --- a/libamu/wire.c +++ b/libamu/wire.c @@ -81,10 +81,6 @@ struct addrlist { }; static addrlist *localnets = NULL; -#ifndef INADDR_NONE -# define INADDR_NONE ((unsigned long) -1) -#endif /* INADDR_NONE */ - #if defined(IFF_LOCAL_LOOPBACK) && !defined(IFF_LOOPBACK) # define IFF_LOOPBACK IFF_LOCAL_LOOPBACK #endif /* defined(IFF_LOCAL_LOOPBACK) && !defined(IFF_LOOPBACK) */ -- 2.43.0