From 0da19af0b8c8b8d8bd19a262479d49d8061c0c13 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Arve=20Hj=C3=B8nnev=C3=A5g?= Date: Mon, 14 Apr 2008 21:35:25 -0700 Subject: [PATCH] printk: Fix log_buf_copy termination. If idx was non-zero and the log had wrapped, len did not get truncated to stop at the last byte written to the log. --- kernel/printk.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/kernel/printk.c b/kernel/printk.c index c78ed88446d6..cd8fbf3440a8 100644 --- a/kernel/printk.c +++ b/kernel/printk.c @@ -319,8 +319,8 @@ int log_buf_copy(char *dest, int idx, int len) if (idx < 0 || idx >= max) { ret = -1; } else { - if (len > max) - len = max; + if (len > max - idx) + len = max - idx; ret = len; idx += (log_end - max); while (len-- > 0) -- 2.34.1