Re: a few strncpy-related patches

From: Jim Meyering
Date: Mon Aug 20 2012 - 16:47:30 EST


Andi Kleen wrote:
> Jim Meyering <jim@xxxxxxxxxxxx> writes:
>
>> I've seen a few too many cases of strncpy misuse.
>> Looking through linux sources, I spotted/fixed these:
>>
>> [PATCH] ACPI: remove unwarranted use of strncpy
>> [PATCH] fs/9p: avoid debug OOPS when reading a long symlink
>> [PATCH] kmemleak: avoid buffer overrun: NUL-terminate strncpy-copied
>> [PATCH] bfa: avoid buffer overrun for 12-byte model name
>> [PATCH] cifs: remove misleading strncpy: each name has length < 16
>
> Better to convert tham all to strlcpy?
>
> The kernel has it.

Anything is better than strncpy.
Is there consensus here that strlcpy is preferred?
Would the integrator(s) even require consensus?

$ git grep -w strncpy|wc -l
987
$ git grep -w strlcpy|wc -l
1345

In any case, shouldn't fixing bugs and obvious misuse be separate
from any global NSC conversion?
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/