diff options
author | Jim Meyering <jim@meyering.net> | 2012-08-21 03:20:49 -0400 |
---|---|---|
committer | Eric Van Hensbergen <ericvh@gmail.com> | 2012-09-06 14:54:53 -0400 |
commit | ba413ab2ccc49e6aa1ebc3523a75635b5e4a0494 (patch) | |
tree | 616525a5d4954660f290f9130c699002571c05e4 /fs | |
parent | 4cbe5a555fa58a79b6ecbb6c531b8bab0650778d (diff) |
fs/9p: avoid debug OOPS when reading a long symlink
Reading a symlink longer than the given buffer, a p9_debug use would
try to print the link name (not NUL-terminated) using a %s format.
Use %.*s instead, and replace the strncpy+strnlen with functionally
equivalent strlen+memcpy.
Signed-off-by: Jim Meyering <meyering@redhat.com>
Signed-off-by: Eric Van Hensbergen <ericvh@gmail.com>
Diffstat (limited to 'fs')
-rw-r--r-- | fs/9p/vfs_inode.c | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/fs/9p/vfs_inode.c b/fs/9p/vfs_inode.c index cbf9dbb1b2a2..890bed538f9b 100644 --- a/fs/9p/vfs_inode.c +++ b/fs/9p/vfs_inode.c | |||
@@ -1276,12 +1276,12 @@ static int v9fs_readlink(struct dentry *dentry, char *buffer, int buflen) | |||
1276 | } | 1276 | } |
1277 | 1277 | ||
1278 | /* copy extension buffer into buffer */ | 1278 | /* copy extension buffer into buffer */ |
1279 | strncpy(buffer, st->extension, buflen); | 1279 | retval = min(strlen(st->extension)+1, (size_t)buflen); |
1280 | memcpy(buffer, st->extension, retval); | ||
1280 | 1281 | ||
1281 | p9_debug(P9_DEBUG_VFS, "%s -> %s (%s)\n", | 1282 | p9_debug(P9_DEBUG_VFS, "%s -> %s (%.*s)\n", |
1282 | dentry->d_name.name, st->extension, buffer); | 1283 | dentry->d_name.name, st->extension, buflen, buffer); |
1283 | 1284 | ||
1284 | retval = strnlen(buffer, buflen); | ||
1285 | done: | 1285 | done: |
1286 | p9stat_free(st); | 1286 | p9stat_free(st); |
1287 | kfree(st); | 1287 | kfree(st); |