printk: return -EINVAL if the message len is bigger than the buf size
[linux-2.6-block.git] / kernel / printk.c
index 572730bd8a5ccb6ed33372bcedd3fab9fd024584..a2276b9167691f164c0753d1c3f0d6ff0b7090e9 100644 (file)
@@ -880,7 +880,9 @@ static int syslog_print(char __user *buf, int size)
        syslog_seq++;
        raw_spin_unlock_irq(&logbuf_lock);
 
-       if (len > 0 && copy_to_user(buf, text, len))
+       if (len > size)
+               len = -EINVAL;
+       else if (len > 0 && copy_to_user(buf, text, len))
                len = -EFAULT;
 
        kfree(text);