[lkml]   [2017]   [Nov]   [8]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
Messages in this thread
SubjectRe: [PATCH] dell-smbios: fix string overflow
On Wed, Nov 8, 2017 at 8:30 PM,  <> wrote:

>> I recommend using "platform/x86: dell-smbios:" in commit header.

While we (maintainers) are fixing this manually, it would be better if
contributors will do this themselves :-)

>> On 11/08/2017 04:08 AM, Arnd Bergmann wrote:
>> > The new sysfs code overwrites two fixed-length character arrays
>> > that are each one byte shorter than they need to be, to hold
>> > the trailing \0:
>> >
>> > drivers/platform/x86/dell-smbios.c: In function 'build_tokens_sysfs':
>> > drivers/platform/x86/dell-smbios.c:494:42: error: 'sprintf' writing a terminating
>> nul past the end of the destination [-Werror=format-overflow=]
>> > sprintf(buffer_location, "%04x_location",
>> > drivers/platform/x86/dell-smbios.c:494:3: note: 'sprintf' output 14 bytes into a
>> destination of size 13
>> > drivers/platform/x86/dell-smbios.c:506:36: error: 'sprintf' writing a terminating
>> nul past the end of the destination [-Werror=format-overflow=]
>> > sprintf(buffer_value, "%04x_value",
>> > drivers/platform/x86/dell-smbios.c:506:3: note: 'sprintf' output 11 bytes into a
>> destination of size 10
>> Don't need to include the error log in commit message. Just explaining
>> the issue is good enough.
>> >
>> > This changes it to just use kasprintf(), which always gets it right.

Good catch followed by a fix!

> Assuming Darren will do the fixup for title and message as recommended by
> Sathyanarayanan before committing:
> Acked-by: Mario Limonciello <>

> Thanks, for the fix. For my own information and improvement, would you
> share how you caught that? Just added "-Werror=format-overflow=" to CFLAGS?

> I wasn't seeing the compile errors with default flags in my own testing, so I'd like
> to make sure I'm doing better testing in the future.

gcc7 by its default [1], though you need to revert [2].

And always good to remember

% make W=1

which implies some warning, W=2 a lot more.


[2]: commit bd664f6b3e376a8ef4990f87d08271cc2d01ba9a
Author: Linus Torvalds <>
Date: Wed Jul 12 19:25:47 2017 -0700

disable new gcc-7.1.1 warnings for now

With Best Regards,
Andy Shevchenko

 \ /
  Last update: 2017-11-08 21:15    [W:0.080 / U:0.276 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site