lkml.org 
[lkml]   [2014]   [Feb]   [14]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Subject[PATCH 3/5] printk: Add comment about tricky check for text buffer size
Date
There is no check for potential "text_len" overflow. It is not needed
because only valid level is detected. It took me some time to understand why.
It would deserve a comment ;-)

Signed-off-by: Petr Mladek <pmladek@suse.cz>
---
kernel/printk/printk.c | 5 +++++
1 file changed, 5 insertions(+)

diff --git a/kernel/printk/printk.c b/kernel/printk/printk.c
index 54a4439d021c..bc6eed48a454 100644
--- a/kernel/printk/printk.c
+++ b/kernel/printk/printk.c
@@ -1562,6 +1562,11 @@ asmlinkage int vprintk_emit(int facility, int level,
case 'd': /* KERN_DEFAULT */
lflags |= LOG_PREFIX;
}
+ /*
+ * No need to check length here because vscnprintf
+ * put '\0' at the end of the string. Only valid and
+ * newly printed level is detected.
+ */
text_len -= end_of_header - text;
text = (char *)end_of_header;
}
--
1.8.4


\
 
 \ /
  Last update: 2014-02-14 18:21    [W:3.578 / U:0.592 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site