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 ...


(Note, *not* cc'ed to the open-source mailing list -- this has nothing to
do with them.  Does mean that I won't see followups unless cc'ed to me.)

On Sun, 13 Jan 2002, Martin v. Loewis wrote:
> After reading the paper, I find that the border cases of overlapping
> strings for strlcat is not specified...

"If it isn't specified, then the behavior is undefined."  No specification
is *NO SPECIFICATION*, i.e. user code should never depend on it.

> Furthermore, the exact meaning of the return value *is* troubling. The
> paper did not consider the case that dst is not null-terminated within
> siz...

As others have already noted, strings are NUL-terminated by definition, so
the behavior is undefined.  This doesn't mean that the implementation
can't try to do something sensible.  It does mean that there is no promise
of sensible behavior, so user code should never depend on it.

Opinions vary on whether it is kinder to the users, in such a case, to
dump core or to try to do "the right thing".  The former makes it more
likely that the user error will be detected, the latter more likely that
the program can stumble on and continue functioning despite an undetected
error.

                                                          Henry Spencer
                                                       henry@spsystems.net


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