lkml.org 
[lkml]   [2022]   [Jan]   [11]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
SubjectRe: [PATCH v1 1/1] vsprintf: Move space out of string literals in fourcc_string()
From
Date
On 11/01/2022 16.10, Petr Mladek wrote:
> On Tue 2022-01-11 13:28:21, Andy Shevchenko wrote:

>>>> - strcpy(p, orig & BIT(31) ? " big-endian" : " little-endian");
>>>> + *p++ = ' ';
>>>> + strcpy(p, orig & BIT(31) ? "big-endian" : "little-endian");
>>>> p += strlen(p);
>>>
>>> Hm, ok, those two strings do occur a lot with of_property_read_bool()
>>> and friends. But if you're micro-optimizing anyway, why not drop the
>>> strlen() and say p = stpcpy(...) instead?
>>
>> Why not? I'll do it for v2.
>
> It is safe here. I just hope that it will not trigger reports from
> some tools looking for potential security issues ;-)
>

strcpy() and stpcpy() have exactly the same preconditions and are safe
in exactly the same circumstances, they only differ in their return
value, so I don't see how any tool would warn about a use of (the
only-recently-standardized) stpcpy if it didn't already warn about strcpy.

Rasmus

\
 
 \ /
  Last update: 2022-01-11 17:15    [W:0.057 / U:1.712 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site