* include/am_compat.h (INADDR_NONE): define in a common location,
authorErez Zadok <ezk@cs.sunysb.edu>
Thu, 6 Oct 2005 20:18:15 +0000 (20:18 +0000)
committerErez Zadok <ezk@cs.sunysb.edu>
Thu, 6 Oct 2005 20:18:15 +0000 (20:18 +0000)
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
amd/amd.h
amd/amfs_auto.c
amd/amfs_toplvl.c
amd/opts.c
fixmount/fixmount.c
include/am_compat.h
libamu/wire.c

index 2a0f122af866545cbd06faad38ef86871f5d33e9..2361ad5fcdde021abd06a99634a7dce04b718457 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,26 @@
+2005-10-06  Erez Zadok  <ezk@cs.sunysb.edu>
+
+       * 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  <ro@TechFak.Uni-Bielefeld.DE>
+
+       * 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  <ezk@cs.sunysb.edu>
 
        * amq/pawd.c (transform_dir): use TCP first, else UDP.  Destroy
index a950a3cca2ec065200170a0b666bf3256bcaf9d4..b4c70f9d2a4272854ebd43c4cca62f38bd71ed3a 100644 (file)
--- 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.
index edf2067340b7986e158ca988893cca5d8e93bd80..3589cbd033b01f3ffc7323faa526280a6406800c 100644 (file)
@@ -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);
index 197e0fbe4395339eb8392e306405b60c9a9676b0..0ad29575256b18a6e626d77f61f96fe06a564766 100644 (file)
@@ -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 */
   {
index b134490bfdd534d891271a6b8520a5e8f630800f..6773e700edca927367da0d50ca9aca3860e40406 100644 (file)
@@ -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);
     }
index 47ee11b9049d4b538527e2ff8ced528414980ac7..376d8c14721426c1cd466f4bd0d27da86781874a 100644 (file)
 #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
index 79453296553cb1692d1280e6a8fa4aeadbdb08a4..a430e16219fbc5e56b1fbf84ca90f1ca3eb2c96d 100644 (file)
@@ -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 */
index 827a5b2208894d349a9fca27f5983af83770c7f6..2a1c44cfb8e6b42f8c9a2c0475f98347dc66eb7d 100644 (file)
@@ -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) */