Re: [PATCH] tty: serial: samsung: Fix potential buffer overflow in clkname

From: jiang.peng9
Date: Wed Apr 02 2025 - 02:28:24 EST


>>> Same comments as with other patches, not possible, IMO. Plus this patch
>>> looks actually worse - commit msg is hardly readable.
>>>
>>> Best regards,
>>> Krzysztof
>>
>> Hi Krzysztof,
>> Thank you for your feedback. Let me briefly re-explain the change:
>> The issue:
>> When building with W=1, we get a format-overflow warning because "clk_uart_baud%d" could write 15-17 bytes >(14 chars + 1-3 digits) into a 15-byte buffer.
>
> Hi,
>
> how did you come to "1-3 digits"?

Hi jirislaby,

Thanks for the follow-up! Let me clarify:

Since num_clks is an unsigned char, it could technically go up to 255. The compiler’s analysis seems to align with this.

While I’m not sure if real-world usage ever needs 3-digit values (like 100+), addressing the warning proactively seems worthwhile.

The change eliminates the compiler warning while adding minimal overhead. Better safe than sorry!

Happy to refine this further if you’d prefer a different approach.

Best regards
Peng Jiang