Richard said:
Ioannis Vranos said:
Only the FUD Standard. The "secure" variants are mentioned (briefly) here:
http://msdn.microsoft.com/vstudio/tour/vs2005_guided_tour/VS2005pro/Framework/CPlusSafeLibraries.htm
The basic idea is:
1) take a function that is perfectly secure if used properly, but which can
be used improperly;
and it *was* used improperly a million of times except by geniueses like
heathfield.
Take gets() for instance.
2) write a version with a trailing _s on the name, which imposes a runtime
performance penalty not only on those who don't know how to use the
original function properly (which would be fair enough) but also on those
who do;
The performance penalty in most cases will be of the order of a few
integer comparisons. This is a non-issue, since many of
the unsecure functions will be thousands or ten thousands of
instructions. Making a few checks and giving a reasonable and
defined outcome for error cases is just error handling.
3) scare people away from the original functions by claiming that they are
insecure and "deprecated";
They are surely insecure:
printf("%s\n",string);
there is NO WAY to limit output in this specific case.
Not to speak about gets() or other goodies that the C standard
allowed.
4) sit back in contentment at having contributed just a little to the
success of Gates's Law.
Empty talk. If Mr Gates says
2+2 is 4
I will NOT say otherwise even if I risk being treated as a "traitor
that accepts Gates Law".
The canonical example, strcpy_s, "prevents" buffer overruns by taking a
length parameter, it is claimed. The claim is, of course, spurious.
Heathfield misses all other specs from strcpy_s. His claims are
spurious.
As an exercise, think up at least one way in which you can overrun a buffer
using strcpy_s. It isn't difficult.
Yes, sure. But a little more difficult than with strcpy isn't it?
Heathfield logic
"Since a perfect world can't exist, a perfect copy function either,
let's keep all buffer overflows and all stupid functions like
strcpy"
lcc-win implements most of this proposal.