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]


On 11/03/2015 08:15 AM, Rich Felker wrote:
I do think this is
guaranteed by other implementations, in terms of both actual behavior
and the implicit requirement not to clobber memory the function is not
specified to clobber.

I don't see any such implicit requirement, so I agree with Florian here.

My impression all along has been that when a function is given an output buffer, it can write whatever it likes to the output buffer, so long as the buffer has the proper value when the function returns. In particular, the caller can't expect the buffer's irrelevant bytes (i.e., bytes not part of the output value) to be preserved. I see nothing in POSIX or in the BSD documentation that requires preservation of irrelevant bytes, either for strlcpy or for POSIX functions in general. So, for example, on POSIX implementations where struct timespec has padding bytes, a caller cannot expect clock_gettime(CLOCK_REALTIME, &ts) to preserve ts's padding bytes, because POSIX doesn't say irrelevant bytes are preserved.

If there's doubt we should clarify with the authors of the original.

This is not an issue that OpenBSD implementers can unilaterally decide now. "Ooops, there's an nonobvious strlcpy feature that we forgot to write down, but all implementations are required to support it anyway."?!? Sorry, but no. That shouldn't work for clock_gettime, and it shouldn't work for strlcpy either.


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