This is the mail archive of the libc-alpha@sourceware.org mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH v4] Implement strlcpy [BZ #178]


Rich Felker wrote:
the fact that it's wrong is actually essential to
some usage patterns like using fgets to read files that may contain
embedded nuls.

Thanks, that's a usage pattern I wasn't familiar with. However, among other things the glibc manual explicitly says that fgets shouldn't be used in that situation, which suggests the ice is quite thin here. So even if POSIX says what you are asserting (I haven't seen specific citations, so I'm still skeptical), as a practical matter applications should not assume that irrelevant bytes in output buffers are preserved.

As far as strlcpy goes perhaps the manual should merely say that it's unspecified what happens to destination bytes after the trailing NUL. We can always specify it later, should POSIX make things clear. I doubt whether applications care much one way or another.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]