printk: Fix log_buf_copy termination.
authorArve Hjønnevåg <arve@android.com>
Tue, 15 Apr 2008 04:35:25 +0000 (21:35 -0700)
committerColin Cross <ccross@android.com>
Thu, 30 Sep 2010 00:49:21 +0000 (17:49 -0700)
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

index 33d6dcdb4909af11f2168b152b66bbb79fe49c90..2d594092d3e16c42b33886acad2935926d974c39 100644 (file)
@@ -290,8 +290,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)