"Richard L. Hamilton" <rlha...@smart.net> wrote:

> > IMHO we should probably keep strcpy()'s behavior the
> > same in this undefined case.
> > It seems likely there is more code out there that
> > expects the old behavior.
>
> It may be prudent to avoid changing "undefined" behavior in cases
> where it's known that a lot of code incorrectly depends on it.

Well, my libtermcap implementation is from 1986 and at that time, the manual
page for strcpy() did definitely not mention that overlapping buffers
may cause problems. The oldest man page that I can find that mentions possible
problems with overlapping buffers is from SunOS-4.1.1 (from 1990). Now let me 
ask: who reads all the man pages for all the functions that all his software
uses again and again on a regular base in order to search for possible 
modifications that _reduce_ usability? And even iff, who remembers all
assumptions he made when writing the code?


> But I think it would be at least as prudent to obtain and apply tools to
> identify the offending usage and fix it.  Otherwise, one is simply covering
> up errors; understandable for maintaining binary compatibility, but
> horrible for improving quality.  Reminds me of AT&T SVR[23] on the 3B15,
> where behavior like /usr/lib/0...@0.so.1 provides was the default; that
> let a lot of bad code keep running, but the result is that the bad code didn't
> get fixed until ported to some system where that was not the default behavior.

This is definitely a different issue as it is a well known fact that 
dereferencing null pointers will cause problems. I know that SVr3 sources for 
many programs did e.g. try to dereference argv[argc] and that it was a well 
known fact that SVr[123] did not come with cleanly written utilities.


> While some degree of backwards binary compatibility with bad behavior of
> other people's code may be justified, IMO it's never justified to leave such
> behavior in code one has control over oneself.
>
> http://valgrind.org/docs/manual/mc-manual.html#mc-manual.overlap

As mentioned, this is a problem that results from reducing usability of 
functions. The oldest man pages that I currently can find that mention
overlapping buffers are from SunOS-4.1.1. BSD-4.3 does neither mention
problems with strcpy() nor does it mention that bcopy() is safe for overlapping
buffers.

Jörg

-- 
 EMail:jo...@schily.isdn.cs.tu-berlin.de (home) Jörg Schilling D-13353 Berlin
       j...@cs.tu-berlin.de                (uni)  
       joerg.schill...@fokus.fraunhofer.de (work) Blog: 
http://schily.blogspot.com/
 URL:  http://cdrecord.berlios.de/private/ ftp://ftp.berlios.de/pub/schily
_______________________________________________
opensolaris-code mailing list
opensolaris-code@opensolaris.org
http://mail.opensolaris.org/mailman/listinfo/opensolaris-code

Reply via email to