Joerg Schilling wrote:
Previous versions of the POSIX standard made no limitations on strcpy()
but the current standard claims that using strcpy() with overlapping
buffers gives undefined results.
Most existing programs have been written before the standard was changed
and I know of a lot of places where strcpy() is called with overlapping buffers
in order to e.g. deal with escaped strings.
I'd like to see that... in my opinion, the use of overlapping buffers in
a program was highly questionable, even without the change in the standard.
I hope there are not many cases where this approach was followed.
It seems that SXCE NV 129 makes use of this change in the standard when in 64
bit mode. While testing my shell "bsh" on SXCE NV 129, it turned out that the
64 bit version does not get correct termcap entries from my libxtermcap and it
turned out that the reason was the 64 bit strcpy() did not copy the
overlapping termcap text buffer correclty while stripping off unneeded parts.
It seems that every call to strcpy() needs to be checked on whether there
are overlapping buffers.
Did someone else notice any strange behavior on SNV 129 that may have been
caused by a similar reason?
I have not heard of any similar cases, but again, I don't know of many
cases (actually I can't think of any others) where the use of
overlapping strings was used with strcpy or friends. (There is memmove,
but that API explicitly permits overlapping regions.)
- Garrett
Jörg
_______________________________________________
opensolaris-code mailing list
opensolaris-code@opensolaris.org
http://mail.opensolaris.org/mailman/listinfo/opensolaris-code