lkml.org 
[lkml]   [2024]   [Mar]   [27]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
SubjectRe: [PATCH 7/9] scsi: mylex: fix sysfs buffer lengths
From
On 3/26/24 23:38, Arnd Bergmann wrote:
> From: Arnd Bergmann <arnd@arndb.de>
>
> The myrb and myrs drivers use an odd way of implementing their sysfs files,
> calling snprintf() with a fixed length of 32 bytes to print into a page
> sized buffer. One of the strings is actually longer than 32 bytes, which
> clang can warn about:
>
> drivers/scsi/myrb.c:1906:10: error: 'snprintf' will always be truncated; specified size is 32, but format string expands to at least 34 [-Werror,-Wformat-truncation]
> drivers/scsi/myrs.c:1089:10: error: 'snprintf' will always be truncated; specified size is 32, but format string expands to at least 34 [-Werror,-Wformat-truncation]
>
> These could all be plain sprintf() without a length as the buffer is
> always long enough. On the other hand, sysfs files should not be overly
> long either, so just double the length to make sure the longest strings
> don't get truncated here.
>
> Fixes: 77266186397c ("scsi: myrs: Add Mylex RAID controller (SCSI interface)")
> Fixes: 081ff398c56c ("scsi: myrb: Add Mylex RAID controller (block interface)")
> Signed-off-by: Arnd Bergmann <arnd@arndb.de>
> ---
> drivers/scsi/myrb.c | 20 ++++++++++----------
> drivers/scsi/myrs.c | 24 ++++++++++++------------
> 2 files changed, 22 insertions(+), 22 deletions(-)
>
Yeah, counting is hard ...

Reviewed-by: Hannes Reinecke <hare@suse.de>

Cheers,

Hannes
--
Dr. Hannes Reinecke Kernel Storage Architect
hare@suse.de +49 911 74053 688
SUSE Software Solutions GmbH, Frankenstr. 146, 90461 Nürnberg
HRB 36809 (AG Nürnberg), GF: I. Totev, A. McDonald, W. Knoblich


\
 
 \ /
  Last update: 2024-05-27 16:10    [W:0.172 / U:0.248 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site