diff options
author | Takashi Iwai <tiwai@suse.de> | 2020-03-22 10:09:11 +0100 |
---|---|---|
committer | David Sterba <dsterba@suse.com> | 2020-03-23 18:14:47 +0100 |
commit | abdd9feb45ed7e9cc55b60a58deba9ca78d46352 (patch) | |
tree | 481a78217c792a93aa330b95202cefa24d7eb807 /drivers/usb/cdns3/gadget.h | |
parent | 39dba8739c4e360d7d1b27119c728791e68b0448 (diff) |
btrfs: sysfs: Use scnprintf() instead of snprintf()
snprintf() is a hard-to-use function, and it's especially difficult to
use it properly for concatenating substrings in a buffer with a limited
size. Since snprintf() returns the would-be-output size, not the actual
size, the subsequent use of snprintf() may point to the incorrect
position easily. Also, returning the value from snprintf() directly to
sysfs show function would pass a bogus value that is higher than the
actually truncated string.
That said, although the current code doesn't actually overflow the
buffer with PAGE_SIZE, it's a usage that shouldn't be done. Or it's
worse; this gives a wrong confidence as if it were doing safe
operations.
This patch replaces such snprintf() calls with a safer version,
scnprintf(). It returns the actual output size, hence it's more
intuitive and the code does what's expected.
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Reviewed-by: David Sterba <dsterba@suse.com>
Signed-off-by: David Sterba <dsterba@suse.com>
Diffstat (limited to 'drivers/usb/cdns3/gadget.h')
0 files changed, 0 insertions, 0 deletions