Re: [PATCH] scsi: hpsa: Replace deprecated strncpy() with strscpy()

2025-02-13 Thread Bart Van Assche
On 2/13/25 3:24 AM, Thorsten Blum wrote: This subtle difference between strncpy() and strscpy() regarding the number of bytes copied isn't really documented anywhere, is it? The documentation I came across so far seems to focus mostly on the different return values of the two functions. From th

Re: [PATCH] scsi: hpsa: Replace deprecated strncpy() with strscpy()

2025-02-13 Thread Thorsten Blum
On 12. Feb 2025, at 23:22, Thorsten Blum wrote: > strncpy() is deprecated for NUL-terminated destination buffers [1]. Use > strscpy() instead and remove the manual NUL-termination. > > Use min() to simplify the size calculation. > > Compile-tested only. > > Link: > https://www.kernel.org/doc/ht

[PATCH] scsi: hpsa: Replace deprecated strncpy() with strscpy()

2025-02-12 Thread Thorsten Blum
strncpy() is deprecated for NUL-terminated destination buffers [1]. Use strscpy() instead and remove the manual NUL-termination. Use min() to simplify the size calculation. Compile-tested only. Link: https://www.kernel.org/doc/html/latest/process/deprecated.html#strncpy-on-nul-terminated-string

Re: [PATCH] scsi: hpsa: replace deprecated strncpy with strscpy/kmemdup_nul

2023-10-26 Thread Kees Cook
On Thu, Oct 26, 2023 at 01:47:32AM +, Justin Stitt wrote: > strncpy() is deprecated for use on NUL-terminated destination strings > [1] and as such we should prefer more robust and less ambiguous string > interfaces. > > This whole process of 1) determining smaller length so we don't overread

[PATCH] scsi: hpsa: replace deprecated strncpy with strscpy/kmemdup_nul

2023-10-25 Thread Justin Stitt
strncpy() is deprecated for use on NUL-terminated destination strings [1] and as such we should prefer more robust and less ambiguous string interfaces. This whole process of 1) determining smaller length so we don't overread the buffer and 2) manually NUL-terminating our buffer so we can use in s