lkml.org 
[lkml]   [2020]   [Aug]   [25]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
From
SubjectRE: [PATCH] usb: atm: don't use snprintf() for sysfs attrs
Date
From: Alex Dewar
> Sent: 24 August 2020 23:23
> kernel/cpu.c: don't use snprintf() for sysfs attrs
>
> As per the documentation (Documentation/filesystems/sysfs.rst),
> snprintf() should not be used for formatting values returned by sysfs.
>
> In all of these cases, sprintf() suffices as we know that the formatted
> strings will be less than PAGE_SIZE in length.

Hmmmm....
I much prefer to see bounded string ops.
sysfs really ought to be passing through the buffer length.
The buffer size should probably be SYSFS_BUF_LEN not PAGE_SIZE
(even it happens to typically be the same).
If PAGE_SIZE is big (or small) passing a 4k buffer may be
more appropriate than a PAGE_SIZE one.

David

-
Registered Address Lakeside, Bramley Road, Mount Farm, Milton Keynes, MK1 1PT, UK
Registration No: 1397386 (Wales)

\
 
 \ /
  Last update: 2020-08-25 10:13    [W:0.228 / U:0.452 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site