Re: strncpy clarify result may not be null terminated

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

 



On 11/8/23 14:11, Alejandro Colomar wrote:
I just don't think we need,
as GNU or Linux projects, to be restricted to the decisions of ISO.  We
can realize that certain functions are bad, and mark them as deprecated
in our scope.

There's enough use of strncpy for the intended use (smallish fixed size character arrays that are null padded, not null terminated) that saying it's deprecated would likely cause more trouble than it's worth. It's not just utmp and tar; it's also socket programming (sun_path) and I'm sure other stuff.

Were we designing the C library from scratch I'd agree with you: in that context, strncpy would clearly be more trouble than it's worth. But now that we're stuck with strncpy we have better things to do than try to deprecate it.

Instead of saying "deprecate" I suggest we say something like "This function is generally a poor choice for processing strings" and point to the longer man page about strings in general. That's what the glibc manual does and it works reasonably well.



[Index of Archives]     [Kernel Documentation]     [Netdev]     [Linux Ethernet Bridging]     [Linux Wireless]     [Kernel Newbies]     [Security]     [Linux for Hams]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux Admin]     [Samba]

  Powered by Linux