Re: [PATCH 05/11] test_hexdump: avoid string truncation warning

Justin Stitt
2024-04-08T19:53:18Z

Hi,

On Mon, Apr 8, 2024 at 8:38 AM Arnd Bergmann <arnd@arndb.de> wrote:
>
> You are correct. I do understand the nuances between strncpy()
> and strscpy(), but I failed to read this file properly.

Arnd, I know you understand these differences. I did not intend to
patronize, so sorry about that. My intention was to provide ample
context for future travelers/reviewers. These replacements can be
tricky sometimes.

>
> I'm still not entirely sure, but from my current reading, I think
> we can just use memcpy() to replace the strncpy() here, as both
> the input string data_b[] and the output real[TEST_HEXDUMP_BUF_SIZE]
> are sized to cover every possible 'len' value. This also follows
> what Linus did for the other original strncpy in b1286ed7158e
> ("test_hexdump: use memcpy instead of strncpy()").
>
> I've reworked the patch based on that assumption now and rewritten
> the changelog text accordingly.

Great! This helps towards https://github.com/KSPP/linux/issues/90

>
> Arnd

Thanks
Justin