[PATCH] Set behavior of sprintf-like functions with overlapping source and destination
Paul Eggert
eggert@cs.ucla.edu
Thu Dec 20 23:25:00 GMT 2018
Dumb question: if fortification is enabled, why can't sprintf-like
functions report an error when the source and destination overlap? The
point of fortification is to catch and report undefined behavior when
it's easy, as is the case here.
> /* Test the sprintf (buf, "%s", buf) does not override buf.
I'm leery of adding this test case, as it tests undefined behavior that
the glibc manual does not document as an extension (and it shouldn't be
documented either).
Traditionally we didn't worry about breaking code like PughUtils.c's
'sprintf(mess,"%s %d",mess,...)' under the principle that such code was
already broken. Why depart from that tradition here?
More information about the Libc-alpha
mailing list