diff options
Diffstat (limited to 'xlators/nfs/server')
-rw-r--r-- | xlators/nfs/server/src/mount3.c | 44 | ||||
-rw-r--r-- | xlators/nfs/server/src/mount3udp_svc.c | 2 | ||||
-rw-r--r-- | xlators/nfs/server/src/nfs-fops.c | 2 | ||||
-rw-r--r-- | xlators/nfs/server/src/nfs3-helpers.c | 14 |
4 files changed, 36 insertions, 26 deletions
diff --git a/xlators/nfs/server/src/mount3.c b/xlators/nfs/server/src/mount3.c index 187c975081d..f3d7def64d0 100644 --- a/xlators/nfs/server/src/mount3.c +++ b/xlators/nfs/server/src/mount3.c @@ -761,6 +761,7 @@ mnt3svc_lookup_mount_cbk (call_frame_t *frame, void *cookie, char *path = NULL; uuid_t mountid = {1, }; char fhstr[1536]; + int alloclen = 0; req = (rpcsvc_request_t *)frame->local; @@ -786,14 +787,16 @@ mnt3svc_lookup_mount_cbk (call_frame_t *frame, void *cookie, if (status != MNT3_OK) goto xmit_res; - path = GF_CALLOC (PATH_MAX, sizeof (char), gf_nfs_mt_char); + alloclen = strlen(mntxl->name) + 2; + path = GF_MALLOC (alloclen, gf_nfs_mt_char); if (!path) { - gf_msg (GF_MNT, GF_LOG_ERROR, ENOMEM, NFS_MSG_NO_MEMORY, - "Out of memory"); + gf_msg (GF_MNT, GF_LOG_ERROR, ENOMEM, + NFS_MSG_NO_MEMORY, + "Memory allocation failed."); goto xmit_res; } - snprintf (path, PATH_MAX, "/%s", mntxl->name); + snprintf (path, alloclen, "/%s", mntxl->name); mnt3svc_update_mountlist (ms, req, path, NULL); GF_FREE (path); if (gf_nfs_dvm_off (nfs_state (ms->nfsx))) { @@ -1148,18 +1151,19 @@ mnt3_resolve_subdir_cbk (call_frame_t *frame, void *cookie, xlator_t *this, nfs3_fh_build_child_fh (&mres->parentfh, buf, &fh); if (strlen (mres->remainingdir) <= 0) { - size_t alloclen; + int alloclen; op_ret = -1; mntstat = MNT3_OK; /* Construct the full path */ + int resolveloc_path_len = strlen(mres->resolveloc.path); alloclen = strlen (mres->exp->expname) + - strlen (mres->resolveloc.path) + 1; - mres->exp->fullpath = GF_CALLOC (alloclen, sizeof (char), - gf_nfs_mt_char); + resolveloc_path_len + 1; + mres->exp->fullpath = GF_MALLOC (alloclen, gf_nfs_mt_char); if (!mres->exp->fullpath) { - gf_msg (GF_MNT, GF_LOG_CRITICAL, ENOMEM, - NFS_MSG_NO_MEMORY, "Allocation failed."); + gf_msg (GF_MNT, GF_LOG_ERROR, ENOMEM, + NFS_MSG_NO_MEMORY, + "Memory allocation failed."); goto err; } snprintf (mres->exp->fullpath, alloclen, "%s%s", @@ -1178,7 +1182,9 @@ mnt3_resolve_subdir_cbk (call_frame_t *frame, void *cookie, xlator_t *this, goto err; } - path = GF_CALLOC (PATH_MAX, sizeof (char), gf_nfs_mt_char); + alloclen = strlen (mres->exp->vol->name) + + resolveloc_path_len + 2; + path = GF_MALLOC (alloclen, gf_nfs_mt_char); if (!path) { gf_msg (GF_MNT, GF_LOG_ERROR, ENOMEM, NFS_MSG_NO_MEMORY, @@ -1190,7 +1196,7 @@ mnt3_resolve_subdir_cbk (call_frame_t *frame, void *cookie, xlator_t *this, */ __mnt3_build_mountid_from_path (authorized_path, fh.mountid); - snprintf (path, PATH_MAX, "/%s%s", mres->exp->vol->name, + snprintf (path, alloclen, "/%s%s", mres->exp->vol->name, mres->resolveloc.path); mnt3svc_update_mountlist (mres->mstate, mres->req, @@ -1293,12 +1299,12 @@ mnt3_readlink_cbk (call_frame_t *frame, void *cookie, xlator_t *this, /* Building the actual mount path to be mounted */ path_len = strlen (mres->exp->vol->name) + strlen (absolute_path) + strlen (mres->remainingdir) + 1; - real_loc = GF_CALLOC (1, path_len, gf_nfs_mt_char); + real_loc = GF_MALLOC (path_len, gf_nfs_mt_char); if (!real_loc) { ret = -ENOMEM; goto mnterr; } - sprintf (real_loc , "%s%s", mres->exp->vol->name, absolute_path); + snprintf (real_loc, path_len, "%s%s", mres->exp->vol->name, absolute_path); gf_path_strip_trailing_slashes (real_loc); /* There may entries after symlink in the mount path, @@ -2314,7 +2320,7 @@ __build_mountlist (struct mount3_state *ms, int *count) if (!first) first = mlist; - mlist->ml_directory = GF_CALLOC (namelen + 2, sizeof (char), + mlist->ml_directory = GF_MALLOC (namelen + 2, gf_nfs_mt_char); if (!mlist->ml_directory) { gf_msg (GF_MNT, GF_LOG_ERROR, ENOMEM, @@ -2325,7 +2331,7 @@ __build_mountlist (struct mount3_state *ms, int *count) strcpy (mlist->ml_directory, me->exname); namelen = strlen (me->hostname); - mlist->ml_hostname = GF_CALLOC (namelen + 2, sizeof (char), + mlist->ml_hostname = GF_MALLOC (namelen + 2, gf_nfs_mt_char); if (!mlist->ml_hostname) { gf_msg (GF_MNT, GF_LOG_ERROR, ENOMEM, @@ -2654,7 +2660,6 @@ mnt3_xlchildren_to_exports (rpcsvc_t *svc, struct mount3_state *ms) if (!nfs_subvolume_started (nfs, ent->vol)) continue; - namelen = strlen (ent->expname) + 1; elist = GF_CALLOC (1, sizeof (*elist), gf_nfs_mt_exportnode); if (!elist) { gf_msg (GF_MNT, GF_LOG_ERROR, ENOMEM, @@ -2663,7 +2668,8 @@ mnt3_xlchildren_to_exports (rpcsvc_t *svc, struct mount3_state *ms) } if (!first) first = elist; - elist->ex_dir = GF_CALLOC (namelen + 2, sizeof (char), + namelen = strlen (ent->expname); + elist->ex_dir = GF_MALLOC (namelen + 2, gf_nfs_mt_char); if (!elist->ex_dir) { gf_msg (GF_MNT, GF_LOG_ERROR, ENOMEM, @@ -3324,7 +3330,7 @@ mnt3_init_export_ent (struct mount3_state *ms, xlator_t *xl, char *exportpath, else alloclen = strlen (xl->name) + 2; - exp->expname = GF_CALLOC (alloclen, sizeof (char), gf_nfs_mt_char); + exp->expname = GF_MALLOC (alloclen, gf_nfs_mt_char); if (!exp->expname) { gf_msg (GF_MNT, GF_LOG_ERROR, ENOMEM, NFS_MSG_NO_MEMORY, "Memory allocation failed"); diff --git a/xlators/nfs/server/src/mount3udp_svc.c b/xlators/nfs/server/src/mount3udp_svc.c index 8256a5970bb..a9499bf0038 100644 --- a/xlators/nfs/server/src/mount3udp_svc.c +++ b/xlators/nfs/server/src/mount3udp_svc.c @@ -110,7 +110,7 @@ mountudpproc3_umnt_3_svc(dirpath **dp, struct svc_req *req) char *mpath = (char *) *dp; xlator_t *nfsx = THIS; - stat = GF_CALLOC (1, sizeof(mountstat3), gf_nfs_mt_mountstat3); + stat = GF_MALLOC (sizeof(mountstat3), gf_nfs_mt_mountstat3); if (stat == NULL) { gf_msg (GF_MNT, GF_LOG_ERROR, ENOMEM, NFS_MSG_NO_MEMORY, "Unable to allocate memory"); diff --git a/xlators/nfs/server/src/nfs-fops.c b/xlators/nfs/server/src/nfs-fops.c index 7c2aab53573..44141001361 100644 --- a/xlators/nfs/server/src/nfs-fops.c +++ b/xlators/nfs/server/src/nfs-fops.c @@ -334,7 +334,7 @@ nfs_gfid_dict (inode_t *inode) int ret = -1; uuid_t rootgfid = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1}; - dyngfid = GF_CALLOC (1, sizeof (uuid_t), gf_common_mt_char); + dyngfid = GF_MALLOC (sizeof (uuid_t), gf_common_mt_char); if (dyngfid == NULL) return (NULL); diff --git a/xlators/nfs/server/src/nfs3-helpers.c b/xlators/nfs/server/src/nfs3-helpers.c index 0b977092fbb..27edf471db2 100644 --- a/xlators/nfs/server/src/nfs3-helpers.c +++ b/xlators/nfs/server/src/nfs3-helpers.c @@ -673,6 +673,7 @@ entry3 * nfs3_fill_entry3 (gf_dirent_t *entry, struct nfs3_fh *dfh) { entry3 *ent = NULL; + int name_len = 0; if ((!entry) || (!dfh)) return NULL; @@ -692,14 +693,15 @@ nfs3_fill_entry3 (gf_dirent_t *entry, struct nfs3_fh *dfh) nfs3_funge_root_dotdot_dirent (entry, dfh); ent->fileid = entry->d_ino; ent->cookie = entry->d_off; - ent->name = GF_CALLOC ((strlen (entry->d_name) + 1), sizeof (char), - gf_nfs_mt_char); + name_len = strlen(entry->d_name); + ent->name = GF_MALLOC (name_len + 1, gf_nfs_mt_char); if (!ent->name) { GF_FREE (ent); ent = NULL; goto err; } strcpy (ent->name, entry->d_name); + ent->name[name_len] = '\0'; err: return ent; @@ -732,7 +734,7 @@ nfs3_fh_to_post_op_fh3 (struct nfs3_fh *fh) pfh.handle_follows = 1; - fhp = GF_CALLOC (1, sizeof (*fh), gf_nfs_mt_char); + fhp = GF_MALLOC (sizeof (*fh), gf_nfs_mt_char); if (!fhp) return pfh; @@ -747,6 +749,7 @@ nfs3_fill_entryp3 (gf_dirent_t *entry, struct nfs3_fh *dirfh, uint64_t devid) { entryp3 *ent = NULL; struct nfs3_fh newfh = {{0}, }; + int name_len = 0; if ((!entry) || (!dirfh)) return NULL; @@ -767,14 +770,15 @@ nfs3_fill_entryp3 (gf_dirent_t *entry, struct nfs3_fh *dirfh, uint64_t devid) ent->fileid = entry->d_ino; ent->cookie = entry->d_off; - ent->name = GF_CALLOC ((strlen (entry->d_name) + 1), sizeof (char), - gf_nfs_mt_char); + name_len = strlen (entry->d_name); + ent->name = GF_MALLOC (name_len + 1, gf_nfs_mt_char); if (!ent->name) { GF_FREE (ent); ent = NULL; goto err; } strcpy (ent->name, entry->d_name); + ent->name[name_len] = '\0'; nfs3_fh_build_child_fh (dirfh, &entry->d_stat, &newfh); nfs3_map_deviceid_to_statdev (&entry->d_stat, devid); |