diff options
author | Jim Meyering <jim@meyering.net> | 2012-04-26 12:35:12 -0400 |
---|---|---|
committer | Josef Bacik <josef@redhat.com> | 2012-05-30 10:23:31 -0400 |
commit | f07c9a79f06cd33b1c9c2c4eacb60bafa7e3f310 (patch) | |
tree | 73e493a66005d90f73d00cb3b09c6dc8fd5c18a2 /fs/btrfs | |
parent | 2eec6c8102c62c540c637176271cfdb13d828d7b (diff) |
Btrfs: avoid buffer overrun in btrfs_printk
The buffer read-overrun would be triggered by a printk format
starting with <N>, where N is a single digit. NUL-terminate
after strncpy. Use memcpy, not strncpy, since we know the
string we're copying fits in the destination buffer and
contains no NUL byte.
Signed-off-by: Jim Meyering <meyering@redhat.com>
Diffstat (limited to 'fs/btrfs')
-rw-r--r-- | fs/btrfs/super.c | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/fs/btrfs/super.c b/fs/btrfs/super.c index 2cd32175753d..46b26650415f 100644 --- a/fs/btrfs/super.c +++ b/fs/btrfs/super.c | |||
@@ -188,7 +188,8 @@ void btrfs_printk(struct btrfs_fs_info *fs_info, const char *fmt, ...) | |||
188 | va_start(args, fmt); | 188 | va_start(args, fmt); |
189 | 189 | ||
190 | if (fmt[0] == '<' && isdigit(fmt[1]) && fmt[2] == '>') { | 190 | if (fmt[0] == '<' && isdigit(fmt[1]) && fmt[2] == '>') { |
191 | strncpy(lvl, fmt, 3); | 191 | memcpy(lvl, fmt, 3); |
192 | lvl[3] = '\0'; | ||
192 | fmt += 3; | 193 | fmt += 3; |
193 | type = logtypes[fmt[1] - '0']; | 194 | type = logtypes[fmt[1] - '0']; |
194 | } else | 195 | } else |