tech-kern archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: Usage of strncpy in the kernel



On Sun, Jan 05, 2025 at 06:01:56PM -0800, Greg A. Woods wrote:
 > > > > I used the "l" because like strlcpy they (should) check all the
 > > > > lengths and won't overrun.
 > > >
 > > > I think you may be confusing strlcpy() and strlcat().
 > >
 > > Huh? The difference between strcpy and strlcpy is the "l" and the
 > > length checking.
 > 
 > As I said, there is no "length" checking in strlcpy() _unless_ perhaps
 > one confuses truncation checking with length checking, but even then the
 > truncation checking is left to the caller and it is only tangentially
 > related to the 'size' parameter.

The _point_ of strlcpy is that it checks the _destination_ length,
like plain strcpy doesn't.

-- 
David A. Holland
dholland%netbsd.org@localhost


Home | Main Index | Thread Index | Old Index