]> git.hungrycats.org Git - linux/commitdiff
staging/rts5208: Fix read overflow in memcpy
authorDaniel Micay <danielmicay@gmail.com>
Tue, 6 Jun 2017 04:52:34 +0000 (21:52 -0700)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 26 Sep 2018 06:33:53 +0000 (08:33 +0200)
commit 88a5b39b69ab1828fd4130e2baadd184109cea69 upstream.

Noticed by FORTIFY_SOURCE, this swaps memcpy() for strncpy() to zero-value
fill the end of the buffer instead of over-reading a string from .rodata.

Signed-off-by: Daniel Micay <danielmicay@gmail.com>
[kees: wrote commit log]
Signed-off-by: Kees Cook <keescook@chromium.org>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: Wayne Porter <wporter82@gmail.com>
Signed-off-by: Amit Pundir <amit.pundir@linaro.org>
drivers/staging/rts5208/rtsx_scsi.c

index 0615a7e77576c562121388c5b877eac0b444451a..34cf9dc13acd0eac453e759ed7ac48188514762a 100644 (file)
@@ -539,7 +539,7 @@ static int inquiry(struct scsi_cmnd *srb, struct rtsx_chip *chip)
 
        if (sendbytes > 8) {
                memcpy(buf, inquiry_buf, 8);
-               memcpy(buf + 8, inquiry_string, sendbytes - 8);
+               strncpy(buf + 8, inquiry_string, sendbytes - 8);
                if (pro_formatter_flag) {
                        /* Additional Length */
                        buf[4] = 0x33;