[SCSI] esas2r: fix potential format string flaw
authorKees Cook <keescook@chromium.org>
Wed, 18 Dec 2013 18:00:54 +0000 (10:00 -0800)
committerJames Bottomley <JBottomley@Parallels.com>
Sat, 15 Mar 2014 17:18:58 +0000 (10:18 -0700)
This makes sure format strings cannot leak into the printk call via the
constructed buffer.

Signed-off-by: Kees Cook <keescook@chromium.org>
Acked-by: Bradley Grove <bgrove@attotech.com>
Signed-off-by: James Bottomley <JBottomley@Parallels.com>
drivers/scsi/esas2r/esas2r_log.c

index 9bf285df58ddfc494bc6370779b1d5232d601d2b..a82030aa8577bdcc033c7956077f566cfdc0ca2a 100644 (file)
@@ -165,13 +165,9 @@ static int esas2r_log_master(const long level,
 
                /*
                 * Put a line break at the end of the formatted string so that
-                * we don't wind up with run-on messages.  only append if there
-                * is enough space in the buffer.
+                * we don't wind up with run-on messages.
                 */
-               if (strlen(event_buffer) < buflen)
-                       strcat(buffer, "\n");
-
-               printk(event_buffer);
+               printk("%s\n", event_buffer);
 
                spin_unlock_irqrestore(&event_buffer_lock, flags);
        }