ACPI: NFIT: limit string attribute write
Subsystems (2)
PATCH 1/1 ACPI: NFIT: limit string attribute write
If we're writing what could be an arbitrary sized string into an attribute we should probably use sysfs_emit() just to be safe. Most of the other attriubtes are some sort of integer so unlikely to be an issue so not altered at this time.
Signed-off-by Ben Dooks <[email protected]>
---
v2:
- use sysfs_emit() instead of snprintf.
--- drivers/acpi/nfit/core.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/acpi/nfit/core.c +1 -1
@@ -1579,7 +1579,7 @@ static ssize_t id_show(struct device *dev, {struct nfit_mem *nfit_mem =to_nfit_mem (dev); -return sprintf (buf,"%s\n" , nfit_mem->id); +return snprintf (buf,PAGE_SIZE ,"%s\n" , nfit_mem->id); }static DEVICE_ATTR_RO (id);
Signature · 1 line
2.40.1
Quoted 18 lines · Ben Dooks
If we're writing what could be an arbitrary sized string into an attribute we should probably use
sysfs_emit()just to be safe. Most of the other attriubtes are some sort of integer so unlikely to be an issue so not altered at this time.Signed-off-by Ben Dooks <[email protected]>---
v2:
- usesysfs_emit()instead of snprintf.--- drivers/acpi/nfit/core.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/acpi/nfit/core.c +0
-0
drivers/acpi/nfit/core.c static ssize_t id_show(struct device *dev, · line 1585
Quoted 8 lines
drivers/acpi/nfit/core.c +1
-1@@ -1579,7 +1579,7 @@ static ssize_t id_show(struct device *dev, {struct nfit_mem *nfit_mem =to_nfit_mem (dev); -return sprintf (buf,"%s\n" , nfit_mem->id); +return snprintf (buf,PAGE_SIZE ,"%s\n" , nfit_mem->id); }static DEVICE_ATTR_RO (id);
whoops, forgot to add before hitting ammend...
Signature · 4 lines
Ben Dooks http://www.codethink.co.uk/ Senior Engineer Codethink - Providing Genius https://www.codethink.co.uk/privacy.html