From: Jim Meyering Date: Thu, 26 Apr 2012 16:35:12 +0000 (+0200) Subject: Btrfs: avoid buffer overrun in btrfs_printk X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=f07c9a79f06cd33b1c9c2c4eacb60bafa7e3f310;p=GitHub%2Fexynos8895%2Fandroid_kernel_samsung_universal8895.git Btrfs: avoid buffer overrun in btrfs_printk The buffer read-overrun would be triggered by a printk format starting with , 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 --- 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, ...) va_start(args, fmt); if (fmt[0] == '<' && isdigit(fmt[1]) && fmt[2] == '>') { - strncpy(lvl, fmt, 3); + memcpy(lvl, fmt, 3); + lvl[3] = '\0'; fmt += 3; type = logtypes[fmt[1] - '0']; } else