staging: wilc1000: prevent some overflows in debugfs
authorDan Carpenter <dan.carpenter@oracle.com>
Thu, 4 Jun 2015 08:59:34 +0000 (11:59 +0300)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Mon, 8 Jun 2015 20:09:41 +0000 (13:09 -0700)
Add some limits here so we don't corrupt memory.

Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/staging/wilc1000/wilc_debugfs.c

index 74b9fd5ba27b8198256d048c58812876e797a268..c328208cda29040c8ea8cc4ac8d0ca7a508bcdb6 100644 (file)
@@ -53,6 +53,9 @@ static ssize_t wilc_debug_level_write(struct file *filp, const char *buf, size_t
        char buffer[128] = {};
        int flag = 0;
 
+       if (count > sizeof(buffer))
+               return -EINVAL;
+
        if (copy_from_user(buffer, buf, count)) {
                return -EFAULT;
        }
@@ -99,6 +102,9 @@ static ssize_t wilc_debug_region_write(struct file *filp, const char *buf, size_
        char buffer[128] = {};
        int flag;
 
+       if (count > sizeof(buffer))
+               return -EINVAL;
+
        if (copy_from_user(buffer, buf, count)) {
                return -EFAULT;
        }