readlink

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

 



Seasons greetings Michael,

May I ask, could readlink be updated to use the same wording for null termination like on sprintf, scanf etc?

https://man7.org/linux/man-pages/man2/readlink.2.html

It says:
 "readlink() does not append a null byte to buf"

Perhaps it should say:
 "readlink() does not append a terminating null byte to buf ('\0')"

In addition, is it worth adding a BUGS section to remind that there is no terminating null byte?

"readlink() assumes the caller understands that no terminating null byte ('\0') will be written in the provided buf. If the caller didn't memset the buffer to ('\0') or allocate an extra byte for the terminating null byte, there is a risk the caller could overrun the end of the buffer, or use uninitialised values in the buf."

Finally, perhaps also the EXAMPLES program could be updated to clarify this:

"/* print only nbytes of buf, as it doesn't contain a terminating null byte ('\0') */
printf("'%s' points to '%.*s'\n", argv[1], (int) nbytes, buf);
"

Kind regards
Jonny



[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