diff options
author | Takashi Iwai <tiwai@suse.de> | 2020-03-20 09:44:29 +0100 |
---|---|---|
committer | Takashi Iwai <tiwai@suse.de> | 2020-04-02 20:42:29 +0200 |
commit | dbdd24eaac4ecc482e2d433175c0e82b9f107bef (patch) | |
tree | 6acbf0163b9acb1f88994fee0e9dec92960d2fd1 /drivers/firmware/edd.c | |
parent | ca707b3f00b4f31a6e1eb37e8ae99f15f2bb1fe5 (diff) | |
download | linux-dbdd24eaac4ecc482e2d433175c0e82b9f107bef.tar.gz linux-dbdd24eaac4ecc482e2d433175c0e82b9f107bef.tar.bz2 linux-dbdd24eaac4ecc482e2d433175c0e82b9f107bef.zip |
edd: Use scnprintf() for avoiding potential buffer overflow
Since snprintf() returns the would-be-output size instead of the
actual output size, the succeeding calls may go beyond the given
buffer limit. Fix it by replacing with scnprintf().
Link: https://lore.kernel.org/r/20200320084429.1803-1-tiwai@suse.de
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Diffstat (limited to 'drivers/firmware/edd.c')
-rw-r--r-- | drivers/firmware/edd.c | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/drivers/firmware/edd.c b/drivers/firmware/edd.c index 29906e39ab4b..14d0970a7198 100644 --- a/drivers/firmware/edd.c +++ b/drivers/firmware/edd.c @@ -341,7 +341,7 @@ edd_show_legacy_max_cylinder(struct edd_device *edev, char *buf) if (!info || !buf) return -EINVAL; - p += snprintf(p, left, "%u\n", info->legacy_max_cylinder); + p += scnprintf(p, left, "%u\n", info->legacy_max_cylinder); return (p - buf); } @@ -356,7 +356,7 @@ edd_show_legacy_max_head(struct edd_device *edev, char *buf) if (!info || !buf) return -EINVAL; - p += snprintf(p, left, "%u\n", info->legacy_max_head); + p += scnprintf(p, left, "%u\n", info->legacy_max_head); return (p - buf); } @@ -371,7 +371,7 @@ edd_show_legacy_sectors_per_track(struct edd_device *edev, char *buf) if (!info || !buf) return -EINVAL; - p += snprintf(p, left, "%u\n", info->legacy_sectors_per_track); + p += scnprintf(p, left, "%u\n", info->legacy_sectors_per_track); return (p - buf); } |