From 255b0dc5201b012b0e8f02ea665ba08ab0a4a0d1 Mon Sep 17 00:00:00 2001 From: Anand Avati Date: Tue, 3 Sep 2013 16:01:41 -0700 Subject: gfapi: apply an upper bound on nested symlink resolution In case of nested symlink resolution, implement an upper bound on the number of such nested levels the resolver will descend. This limit is arbitrary, and set to 2048 nested levels. Change-Id: I264e5bd60d317eda97f4e6f49bd5d8694f8664a9 BUG: 1004100 Signed-off-by: Anand Avati Reviewed-on: http://review.gluster.org/5874 Tested-by: Gluster Build System Reviewed-by: Vijay Bellur --- api/src/glfs-resolve.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) (limited to 'api/src/glfs-resolve.c') diff --git a/api/src/glfs-resolve.c b/api/src/glfs-resolve.c index 1dcaddecd24..a6698f8b9ad 100644 --- a/api/src/glfs-resolve.c +++ b/api/src/glfs-resolve.c @@ -368,6 +368,16 @@ glfs_resolve_at (struct glfs *fs, xlator_t *subvol, inode_t *at, char *lpath = NULL; loc_t sym_loc = {0,}; + if (follow > GLFS_SYMLINK_MAX_FOLLOW) { + errno = ELOOP; + ret = -1; + if (inode) { + inode_unref (inode); + inode = NULL; + } + break; + } + ret = glfs_resolve_symlink (fs, subvol, inode, &lpath); inode_unref (inode); inode = NULL; @@ -383,7 +393,7 @@ glfs_resolve_at (struct glfs *fs, xlator_t *subvol, inode_t *at, /* always recurisvely follow while following symlink */ - 1, reval); + follow + 1, reval); if (ret == 0) inode = inode_ref (sym_loc.inode); loc_wipe (&sym_loc); -- cgit