Skip to contentSkip to conversation

scsi: esas2r: fix potential format string flaw

PATCH New Kees Cook 1 participant 1 message Dec 18, 2013

Subsystems (2)
lore
Share & tools
lore

Kees Cook

author
#0 lore raw

PATCH v2 1/1 scsi: esas2r: fix potential format string flaw

This makes sure format strings cannot leak into the printk call via the constructed buffer.

---
v2:
- add newline via printk instead.

---
 drivers/scsi/esas2r/esas2r_log.c |    8 ++------
 1 file changed, 2 insertions(+), 6 deletions(-)
drivers/scsi/esas2r/esas2r_log.c +2 -6
index 9bf285df58dd..a82030aa8577 100644
@@ -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);
 	}
Signature · 6 lines
1.7.9.5


-- 
Kees Cook
Chrome OS Security