From 8a82142898f86225ec9dea6d2dbbb3982627e5f1 Mon Sep 17 00:00:00 2001 From: Erez Zadok Date: Fri, 7 Oct 2005 00:20:13 +0000 Subject: [PATCH] * conf/autofs/autofs_solaris_v2_v3.c (autofs_lookup_2_req) conf/autofs/autofs_solaris_v1.c (autofs_mount_1_req), amd/opts.c, amd/nfs_subr.c (nfsproc_lookup_2_svc), amd/nfs_start.c (mount_automounter), amd/get_args.c (get_args), amd/amfs_toplvl.c, amd/amfs_auto.c (amfs_auto_mount), amd/amd.h, amd/amd.c (main): use sizeof() instead of fixed SIZEOF_* macros. --- ChangeLog | 7 +++++++ amd/amd.c | 2 +- amd/amd.h | 4 ++-- amd/amfs_auto.c | 2 +- amd/amfs_toplvl.c | 20 ++++++++++---------- amd/get_args.c | 4 ++-- amd/nfs_start.c | 2 +- amd/nfs_subr.c | 4 ++-- amd/opts.c | 2 +- conf/autofs/autofs_solaris_v1.c | 4 ++-- conf/autofs/autofs_solaris_v2_v3.c | 8 ++++---- 11 files changed, 33 insertions(+), 26 deletions(-) diff --git a/ChangeLog b/ChangeLog index 7b3e25b..d950e65 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,12 @@ 2005-10-06 Erez Zadok + * conf/autofs/autofs_solaris_v2_v3.c (autofs_lookup_2_req) + conf/autofs/autofs_solaris_v1.c (autofs_mount_1_req), amd/opts.c, + amd/nfs_subr.c (nfsproc_lookup_2_svc), amd/nfs_start.c + (mount_automounter), amd/get_args.c (get_args), amd/amfs_toplvl.c, + amd/amfs_auto.c (amfs_auto_mount), amd/amd.h, amd/amd.c (main): + use sizeof() instead of fixed SIZEOF_* macros. + * libamu/strutil.c (xstrlcat, xstrlcpy), include/am_utils.h (DEBUG): if debugging is on, then also print the source file name and line number that called xstrl* with a buffer that wasn't large diff --git a/amd/amd.c b/amd/amd.c index 42e7a69..fa8f831 100644 --- a/amd/amd.c +++ b/amd/amd.c @@ -456,7 +456,7 @@ main(int argc, char *argv[]) *domdot++ = '\0'; hostdomain = domdot; } - xstrlcpy(hostd, hostname, SIZEOF_HOSTD); + xstrlcpy(hostd, hostname, sizeof(hostd)); am_set_hostname(hostname); /* diff --git a/amd/amd.h b/amd/amd.h index b4c70f9..e0eaef5 100644 --- a/amd/amd.h +++ b/amd/amd.h @@ -637,8 +637,8 @@ extern SVCXPRT *current_transp; /* For nfs_quick_reply() */ extern char *conf_tag; #define SIZEOF_UID_STR 12 #define SIZEOF_GID_STR 12 -extern char *opt_gid; -extern char *opt_uid; +extern char *opt_gid, gid_str[SIZEOF_GID_STR]; +extern char *opt_uid, uid_str[SIZEOF_UID_STR]; extern int NumChildren; extern int fwd_sock; extern int select_intr_valid; diff --git a/amd/amfs_auto.c b/amd/amfs_auto.c index 3589cbd..92be827 100644 --- a/amd/amfs_auto.c +++ b/amd/amfs_auto.c @@ -155,7 +155,7 @@ amfs_auto_mount(am_node *mp, mntfs *mf) 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 0ad2957..c02b013 100644 --- a/amd/amfs_toplvl.c +++ b/amd/amfs_toplvl.c @@ -195,23 +195,23 @@ amfs_toplvl_mount(am_node *mp, mntfs *mf) #ifdef HAVE_FS_AUTOFS if (mf->mf_flags & MFF_IS_AUTOFS) { - autofs_get_opts(opts, SIZEOF_OPTS, mp->am_autofs_fh); + autofs_get_opts(opts, sizeof(opts), mp->am_autofs_fh); } else #endif /* HAVE_FS_AUTOFS */ { preopts[0] = '\0'; #ifdef MNTTAB_OPT_INTR - xstrlcat(preopts, MNTTAB_OPT_INTR, SIZEOF_OPTS); - xstrlcat(preopts, ",", SIZEOF_OPTS); + xstrlcat(preopts, MNTTAB_OPT_INTR, sizeof(preopts)); + xstrlcat(preopts, ",", sizeof(preopts)); #endif /* MNTTAB_OPT_INTR */ #ifdef MNTTAB_OPT_IGNORE - xstrlcat(preopts, MNTTAB_OPT_IGNORE, SIZEOF_OPTS); - xstrlcat(preopts, ",", SIZEOF_OPTS); + xstrlcat(preopts, MNTTAB_OPT_IGNORE, sizeof(preopts)); + xstrlcat(preopts, ",", sizeof(preopts)); #endif /* MNTTAB_OPT_IGNORE */ #ifdef WANT_TIMEO_AND_RETRANS_ON_TOPLVL - xsnprintf(opts, SIZEOF_OPTS, "%s%s,%s=%d,%s=%d,%s=%d,%s,map=%s", + xsnprintf(opts, sizeof(opts), "%s%s,%s=%d,%s=%d,%s=%d,%s,map=%s", #else /* WANT_TIMEO_AND_RETRANS_ON_TOPLVL */ - xsnprintf(opts, SIZEOF_OPTS, "%s%s,%s=%d,%s,map=%s", + xsnprintf(opts, sizeof(opts), "%s%s,%s=%d,%s,map=%s", #endif /* WANT_TIMEO_AND_RETRANS_ON_TOPLVL */ preopts, MNTTAB_OPT_RW, @@ -224,11 +224,11 @@ amfs_toplvl_mount(am_node *mp, mntfs *mf) mf->mf_ops->fs_type, mf->mf_info); #ifdef MNTTAB_OPT_NOAC if (gopt.auto_attrcache == 0) { - xstrlcat(opts, ",", SIZEOF_OPTS); - xstrlcat(opts, MNTTAB_OPT_NOAC, SIZEOF_OPTS); + xstrlcat(opts, ",", sizeof(opts)); + xstrlcat(opts, MNTTAB_OPT_NOAC, sizeof(opts)); } else #endif /* MNTTAB_OPT_NOAC */ - set_auto_attrcache_timeout(preopts, opts, SIZEOF_OPTS); + set_auto_attrcache_timeout(preopts, opts, sizeof(preopts)); } /* now do the mount */ diff --git a/amd/get_args.c b/amd/get_args.c index 11a3696..93a4736 100644 --- a/amd/get_args.c +++ b/amd/get_args.c @@ -382,8 +382,8 @@ get_args(int argc, char *argv[]) hostdomain = gopt.sub_domain; if (*hostdomain == '.') hostdomain++; - xstrlcat(hostd, ".", SIZEOF_HOSTD); - xstrlcat(hostd, hostdomain, SIZEOF_HOSTD); + xstrlcat(hostd, ".", sizeof(hostd)); + xstrlcat(hostd, hostdomain, sizeof(hostd)); #ifdef MOUNT_TABLE_ON_FILE if (amuDebug(D_MTAB)) diff --git a/amd/nfs_start.c b/amd/nfs_start.c index 00ab825..17303bc 100644 --- a/amd/nfs_start.c +++ b/amd/nfs_start.c @@ -368,7 +368,7 @@ mount_automounter(int ppid) if (ret != 0) return ret; } - xsnprintf(pid_fsname, SIZEOF_PID_FSNAME, "%s:(pid%ld,port%u)", + xsnprintf(pid_fsname, sizeof(pid_fsname), "%s:(pid%ld,port%u)", am_get_hostname(), (long) am_mypid, nfs_port); /* security: if user sets -D noamq, don't even create listening socket */ diff --git a/amd/nfs_subr.c b/amd/nfs_subr.c index 8cb8031..9f6486b 100644 --- a/amd/nfs_subr.c +++ b/amd/nfs_subr.c @@ -205,8 +205,8 @@ nfsproc_lookup_2_svc(nfsdiropargs *argp, struct svc_req *rqstp) /* finally, find the effective uid/gid from RPC request */ if (getcreds(rqstp, &uid, &gid, nfsxprt) < 0) plog(XLOG_ERROR, "cannot get uid/gid from RPC credentials"); - xsnprintf(opt_uid, SIZEOF_UID_STR, "%d", (int) uid); - xsnprintf(opt_gid, SIZEOF_GID_STR, "%d", (int) gid); + xsnprintf(opt_uid, sizeof(uid_str), "%d", (int) uid); + xsnprintf(opt_gid, sizeof(gid_str), "%d", (int) gid); mp = fh_to_mp3(&argp->da_fhandle, &retry, VLOOK_CREATE); if (mp == NULL) { diff --git a/amd/opts.c b/amd/opts.c index 6773e70..49b874d 100644 --- a/amd/opts.c +++ b/amd/opts.c @@ -113,7 +113,7 @@ static char *opt_key = nullstr; static char *opt_keyd = nullstr; static char *opt_map = nullstr; static char *opt_path = nullstr; -static char uid_str[SIZEOF_UID_STR], gid_str[SIZEOF_GID_STR]; +char uid_str[SIZEOF_UID_STR], gid_str[SIZEOF_GID_STR]; char *opt_uid = uid_str; char *opt_gid = gid_str; static char *vars[8]; diff --git a/conf/autofs/autofs_solaris_v1.c b/conf/autofs/autofs_solaris_v1.c index 3a3e22f..eb3e5e7 100644 --- a/conf/autofs/autofs_solaris_v1.c +++ b/conf/autofs/autofs_solaris_v1.c @@ -195,8 +195,8 @@ autofs_mount_1_req(struct mntrequest *m, m->name, m->map, m->opts, m->path); /* find the effective uid/gid from RPC request */ - xsnprintf(opt_uid, SIZEOF_UID_STR, "%d", (int) cred->aup_uid); - xsnprintf(opt_gid, SIZEOF_GID_STR, "%d", (int) cred->aup_gid); + xsnprintf(opt_uid, sizeof(uid_str), "%d", (int) cred->aup_uid); + xsnprintf(opt_gid, sizeof(gid_str), "%d", (int) cred->aup_gid); mp = find_ap(m->path); if (!mp) { diff --git a/conf/autofs/autofs_solaris_v2_v3.c b/conf/autofs/autofs_solaris_v2_v3.c index c6e26a6..78c2714 100644 --- a/conf/autofs/autofs_solaris_v2_v3.c +++ b/conf/autofs/autofs_solaris_v2_v3.c @@ -488,8 +488,8 @@ autofs_lookup_2_req(autofs_lookupargs *m, m->path, m->isdirect); /* find the effective uid/gid from RPC request */ - xsnprintf(opt_uid, SIZEOF_UID_STR, "%d", (int) cred->aup_uid); - xsnprintf(opt_gid, SIZEOF_GID_STR, "%d", (int) cred->aup_gid); + xsnprintf(opt_uid, sizeof(uid_str), "%d", (int) cred->aup_uid); + xsnprintf(opt_gid, sizeof(gid_str), "%d", (int) cred->aup_gid); mp = find_ap(m->path); if (!mp) { @@ -556,8 +556,8 @@ autofs_mount_2_req(autofs_lookupargs *m, m->path, m->isdirect); /* find the effective uid/gid from RPC request */ - xsnprintf(opt_uid, SIZEOF_UID_STR, "%d", (int) cred->aup_uid); - xsnprintf(opt_gid, SIZEOF_GID_STR, "%d", (int) cred->aup_gid); + xsnprintf(opt_uid, sizeof(uid_str), "%d", (int) cred->aup_uid); + xsnprintf(opt_gid, sizeof(gid_str), "%d", (int) cred->aup_gid); mp = find_ap(m->path); if (!mp) { -- 2.43.0