This is the mail archive of the libc-alpha@sources.redhat.com 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: [open-source] Re: Wish for 2002 ...


> "Martin v. Loewis" <martin@v.loewis.de> writes:
> 
> |> The case that src is not null-terminated is not
> |> considered at all.
> 
> If the src parameter is specified as a string then there is nothing to
> consider because a string is null-terminated by definition, otherwise it
> is undefined behaviour.

That sounds reasonable; you cannot do better given the interface of
strlcat (if there was a second size argument describing the size of
the src buffer, you could).

The stumbling issue is the asymmetry with the dst string: If it is a
string, then I'd expect that it follows the same rationale. IOW, the
implementation should try to find the end of the string, which may or
may not exist with the memory block; if there is no terminating null,
for dst, the behaviour would be undefined, as well. Surprisingly, the
implementation guarantees well-defined behaviour in this case, at the
cost of deviating from the documented return value.

Regards,
Martin


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