[patch] staging: wilc1000: prevent some overflows in debugfs

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Add some limits here so we don't corrupt memory.

Signed-off-by: Dan Carpenter <dan.carpenter@xxxxxxxxxx>

diff --git a/drivers/staging/wilc1000/wilc_debugfs.c b/drivers/staging/wilc1000/wilc_debugfs.c
index 74b9fd5..c328208 100644
--- a/drivers/staging/wilc1000/wilc_debugfs.c
+++ b/drivers/staging/wilc1000/wilc_debugfs.c
@@ -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;
 	}
_______________________________________________
devel mailing list
devel@xxxxxxxxxxxxxxxxxxxxxx
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel




[Index of Archives]     [Linux Driver Backports]     [DMA Engine]     [Linux GPIO]     [Linux SPI]     [Video for Linux]     [Linux USB Devel]     [Linux Coverity]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [Yosemite Backpacking]
  Powered by Linux