diff options
author | Johan Hovold <johan@hovoldconsulting.com> | 2015-09-01 12:25:27 +0200 |
---|---|---|
committer | Johan Hovold <johan@hovoldconsulting.com> | 2015-09-02 10:47:55 +0200 |
commit | 505c9d27b804f2b1e1e6432a89876df197432bbe (patch) | |
tree | 30c5d3397d8a1b6c5af54d220180cffa0e20b78e /drivers/staging/greybus/interface.c | |
parent | greybus: svc: fix hot-plug-state allocation flag (diff) | |
download | linux-505c9d27b804f2b1e1e6432a89876df197432bbe.tar.gz linux-505c9d27b804f2b1e1e6432a89876df197432bbe.tar.bz2 linux-505c9d27b804f2b1e1e6432a89876df197432bbe.zip |
greybus: interface: fix potential attribute-buffer overflow
Use scnprintf in the generic attribute helper, which does not currently
check for buffer overflow.
The attribute helper is used to print generic strings, which could
potentially overflow the buffer. Note that the only strings currently
exported are taken from greybus string descriptors and should therefore
be limited to 255 chars.
Signed-off-by: Johan Hovold <johan@hovoldconsulting.com>
Reviewed-by: Viresh Kumar <viresh.kumar@linaro.org>
Reviewed-by: Bryan O'Donoghue <bryan.odonoghue@linaro.org>
Diffstat (limited to 'drivers/staging/greybus/interface.c')
-rw-r--r-- | drivers/staging/greybus/interface.c | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/drivers/staging/greybus/interface.c b/drivers/staging/greybus/interface.c index c5211a313d34..0c3613e16d57 100644 --- a/drivers/staging/greybus/interface.c +++ b/drivers/staging/greybus/interface.c @@ -16,7 +16,7 @@ static ssize_t field##_show(struct device *dev, \ char *buf) \ { \ struct gb_interface *intf = to_gb_interface(dev); \ - return sprintf(buf, "%"#type"\n", intf->field); \ + return scnprintf(buf, PAGE_SIZE, "%"#type"\n", intf->field); \ } \ static DEVICE_ATTR_RO(field) |