Commit 505c9d27 authored by Johan Hovold's avatar Johan Hovold

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: default avatarJohan Hovold <johan@hovoldconsulting.com>
Reviewed-by: default avatarViresh Kumar <viresh.kumar@linaro.org>
Reviewed-by: default avatarBryan O'Donoghue <bryan.odonoghue@linaro.org>
parent 287bba82
......@@ -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)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment