symlink: limit symlink depth to avoid following cyclical links

/* msdn: There is a maximum of 31 reparse points (and
 * therefore symbolic links) allowed in a particular path. */
#define NFS41_MAX_SYMLINK_DEPTH     31

also added checks for the return value of nfs41_symlink_target() on open/link/rename

Signed-off-by: Casey Bodley <cbodley@citi.umich.edu>
This commit is contained in:
Casey Bodley 2010-10-15 16:08:16 -04:00 committed by unknown
parent 59526ba9d8
commit 870b389e8f
4 changed files with 41 additions and 0 deletions

View file

@ -152,6 +152,7 @@ int nfs41_symlink_follow(
{
nfs41_abs_path path;
nfs41_path_fh file;
uint32_t depth = 0;
int status = NO_ERROR;
file.path = &path;
@ -160,6 +161,11 @@ int nfs41_symlink_follow(
dprintf(2, "--> nfs41_symlink_follow('%s')\n", symlink->path->path);
do {
if (++depth > NFS41_MAX_SYMLINK_DEPTH) {
status = ERROR_TOO_MANY_LINKS;
goto out;
}
/* construct the target path */
status = nfs41_symlink_target(session, symlink, &path);
if (status) goto out;