summaryrefslogtreecommitdiff
path: root/fs/9p
diff options
context:
space:
mode:
authorMartin Stava <martin.stava@gmail.com>2009-11-02 08:39:34 -0600
committerEric Van Hensbergen <ericvh@gmail.com>2009-11-02 08:43:45 -0600
commit2511cd0b3b9e9b1c3e9360cc565c3745ac3f3f3f (patch)
tree70fff7f686a9c6c956146e39f656412715d40996 /fs/9p
parentf91b90993f0d286be89f06c2f547ced8cfe291c6 (diff)
downloadlinux-3.10-2511cd0b3b9e9b1c3e9360cc565c3745ac3f3f3f.tar.gz
linux-3.10-2511cd0b3b9e9b1c3e9360cc565c3745ac3f3f3f.tar.bz2
linux-3.10-2511cd0b3b9e9b1c3e9360cc565c3745ac3f3f3f.zip
9p: fix readlink
I do not know if you've looked on the patch, but unfortunately it is incorrect. A suggested better version is in this email (the old version didn't work in case the user provided buffer was not long enough - it incorrectly appended null byte on a position of last char, and thus broke the contract of the readlink method). However, I'm still not sure this is 100% correct thing to do, I think readlink is supposed to return buffer without last null byte in all cases, but we do return last null byte (even the old version).. on the other hand it is likely unspecified what is in the remaining part of the buffer, so null character may be fine there ;): Signed-off-by: Martin Stava <martin.stava@gmail.com> Signed-off-by: Eric Van Hensbergen <ericvh@gmail.com>
Diffstat (limited to 'fs/9p')
-rw-r--r--fs/9p/vfs_inode.c5
1 files changed, 2 insertions, 3 deletions
diff --git a/fs/9p/vfs_inode.c b/fs/9p/vfs_inode.c
index 5947628aefe..18f74ec4dce 100644
--- a/fs/9p/vfs_inode.c
+++ b/fs/9p/vfs_inode.c
@@ -994,8 +994,7 @@ static int v9fs_readlink(struct dentry *dentry, char *buffer, int buflen)
P9_DPRINTK(P9_DEBUG_VFS,
"%s -> %s (%s)\n", dentry->d_name.name, st->extension, buffer);
- retval = buflen;
-
+ retval = strnlen(buffer, buflen);
done:
kfree(st);
return retval;
@@ -1062,7 +1061,7 @@ static void *v9fs_vfs_follow_link(struct dentry *dentry, struct nameidata *nd)
__putname(link);
link = ERR_PTR(len);
} else
- link[len] = 0;
+ link[min(len, PATH_MAX-1)] = 0;
}
nd_set_link(nd, link);