mmc: core: use sysfs_emit() instead of sprintf()
sprintf() (still used in the MMC core for the sysfs output) is vulnerable to the buffer overflow. Use the new-fangled sysfs_emit() instead. Found by Linux Verification Center (linuxtesting.org) with the SVACE static analysis tool. Signed-off-by: Sergey Shtylyov <s.shtylyov@omp.ru> Cc: stable@vger.kernel.org Link: https://lore.kernel.org/r/717729b2-d65b-c72e-9fac-471d28d00b5a@omp.ru Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
This commit is contained in:
committed by
Ulf Hansson
parent
75a2f412d0
commit
f5d8a5fe77
@@ -7,6 +7,7 @@
|
||||
|
||||
#include <linux/err.h>
|
||||
#include <linux/pm_runtime.h>
|
||||
#include <linux/sysfs.h>
|
||||
|
||||
#include <linux/mmc/host.h>
|
||||
#include <linux/mmc/card.h>
|
||||
@@ -40,9 +41,9 @@ static ssize_t info##num##_show(struct device *dev, struct device_attribute *att
|
||||
\
|
||||
if (num > card->num_info) \
|
||||
return -ENODATA; \
|
||||
if (!card->info[num-1][0]) \
|
||||
if (!card->info[num - 1][0]) \
|
||||
return 0; \
|
||||
return sprintf(buf, "%s\n", card->info[num-1]); \
|
||||
return sysfs_emit(buf, "%s\n", card->info[num - 1]); \
|
||||
} \
|
||||
static DEVICE_ATTR_RO(info##num)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user