summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAnand Avati <avati@redhat.com>2013-09-03 16:01:41 -0700
committerVijay Bellur <vbellur@redhat.com>2013-09-05 05:26:30 -0700
commit2a1f445d30f2d57951a4d5582c1d9b1f675ad704 (patch)
tree9d9d7ddadebc1ce2a6a1d89de145bc2378bf746d
parent4b317e64cafe1e8621a8b24ebb8243931cda264a (diff)
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 <avati@redhat.com> Reviewed-on: http://review.gluster.org/5768 Tested-by: Gluster Build System <jenkins@build.gluster.com> Reviewed-by: Raghavendra Talur <rtalur@redhat.com> Reviewed-by: Vijay Bellur <vbellur@redhat.com>
-rw-r--r--api/src/glfs-internal.h2
-rw-r--r--api/src/glfs-resolve.c12
2 files changed, 13 insertions, 1 deletions
diff --git a/api/src/glfs-internal.h b/api/src/glfs-internal.h
index 30ff599..c7fdf75 100644
--- a/api/src/glfs-internal.h
+++ b/api/src/glfs-internal.h
@@ -14,6 +14,8 @@
#include "xlator.h"
+#define GLFS_SYMLINK_MAX_FOLLOW 2048
+
struct glfs;
typedef int (*glfs_init_cbk) (struct glfs *fs, int ret);
diff --git a/api/src/glfs-resolve.c b/api/src/glfs-resolve.c
index ec8890b..104fc9e 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);