summaryrefslogtreecommitdiff
path: root/drivers/iio
diff options
context:
space:
mode:
authorKees Cook <keescook@chromium.org>2014-03-13 16:46:00 (GMT)
committerJonathan Cameron <jic23@kernel.org>2014-03-15 14:45:14 (GMT)
commit598db5816664472e1649ef94b0ba4c5cc1b9f3b4 (patch)
tree4b65ace56d7a9e5617dc98bd8af60986affd415c /drivers/iio
parent24e7d7990179e5ed38e90d78d12c25fa201c618a (diff)
downloadlinux-598db5816664472e1649ef94b0ba4c5cc1b9f3b4.tar.xz
iio: force snprintf for PAGE_SIZE bufs
This is a tiny preventative measure to make sure we can't write beyond PAGE_SIZE on the buffers being used in sysfs for iio. There is currently no way for this to happen, but the change makes this code more robust for the future. Signed-off-by: Kees Cook <keescook@chromium.org> Signed-off-by: Jonathan Cameron <jic23@kernel.org>
Diffstat (limited to 'drivers/iio')
-rw-r--r--drivers/iio/industrialio-core.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/drivers/iio/industrialio-core.c b/drivers/iio/industrialio-core.c
index ede16aec..1375921 100644
--- a/drivers/iio/industrialio-core.c
+++ b/drivers/iio/industrialio-core.c
@@ -340,7 +340,7 @@ ssize_t iio_enum_read(struct iio_dev *indio_dev,
else if (i >= e->num_items)
return -EINVAL;
- return sprintf(buf, "%s\n", e->items[i]);
+ return snprintf(buf, PAGE_SIZE, "%s\n", e->items[i]);
}
EXPORT_SYMBOL_GPL(iio_enum_read);
@@ -820,7 +820,7 @@ static ssize_t iio_show_dev_name(struct device *dev,
char *buf)
{
struct iio_dev *indio_dev = dev_to_iio_dev(dev);
- return sprintf(buf, "%s\n", indio_dev->name);
+ return snprintf(buf, PAGE_SIZE, "%s\n", indio_dev->name);
}
static DEVICE_ATTR(name, S_IRUGO, iio_show_dev_name, NULL);