Re: [PATCH v1 1/1] vsprintf: Move space out of string literals in fourcc_string()
From: Rasmus Villemoes
Date: Tue Jan 11 2022 - 11:14:48 EST
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