Re: security enhacement to C runtime library (XXX_s)



On Apr 5, 4:31 am, "artun" <muratar...@xxxxxxxxx> wrote:
Hello,

In the below link MS announces a security update to the C runtime
library which most of the group members are possibly aware of:
http://msdn2.microsoft.com/en-us/library/8ef0s5kh(VS.80).aspx

As far as I could understand with this still non-standard approach,
the error is detected in more details. So by using a XXX_s version of
a runtime library function we can have more detailed knowledge about
the source of the error that causes the security defect. However, if
our code is a cross platform standard C code we loose the standard.

Correct. From a practical point of view, all updates to the ANSI C
standard, including future proposal are, at this point, is the same
category as non-portable compiler specific extensions. This library
proposal is no exception.

I want to discuss if this security enhancement covered in XXX_s like
functions is still necessary.

Can we achieve the same security by by giving the length (i.e. using
snprintf instead of sprintf) with some loose of extra knowledge?

Mostly, yes. And conversely this library can lose its supposed safety
by putting wrong values for these lengths, (or overly large lengths
such as RSIZE_MAX that lead to a "do nothing" for the length check).
You should not be deceived by the name of this proposal, remember that
Microsoft has a very active PR department. Though, the library does
propose a few functions that solve the re-entrancy issue.

Objectively speaking this proposal changes the way in which buffer
overflow errors occur rather than going to any trouble to solving
them. Every buffer overflow error that was made before can still be
made, its just that the results might be different. There are also
new error modes introduced -- namely mismatching the length with the
buffers.

You see, buffer overflows basically happen because people want to use
strings in C the way they are used in every other programming
language. But the programmer makes some sort of error in which they
have ignored or omitted considerations for the limits of the C-style
strings. This proposal is trying to make these limitations more
apparent, and thus they think they are addressing the problem. But,
it doesn't address the core issue which is that programmers want to
use strings in C like they do in every other language.

So the remaining question becomes: how can we increase the programmer
safety (perhaps by making a proposal for strings that more closely
matches what programmers want) with strings in C while remaining
portable? The answer is in my last signature link.

--
Paul Hsieh
http://www.pobox.com/~qed/
http://bstring.sf.net/

.



Relevant Pages

  • Brian Kernighan, maybe Im not worthy, maybe Im scum
    ... It's a critique of the "Beautiful" code authored by ... Rob Pike and discussed by Brian Kernighan in a new O'Reilly book. ... programmer, right? ... strings, only for what we call in .Net, sbyte, strings o' bytes. ...
    (comp.programming)
  • Re: A note on personal corruption as a result of using C
    ... Why did you feel the need to handle NULs in strings? ... A bad programmer can recreate Fortran in any language. ... It troubled mathematicians that the square root of minus one seemed to ...
    (comp.programming)
  • Re: Is it time for secure C ?
    ... This is certainly possible (especially with C99 VLAs ... but is the proposed "security" worth ... array out with NUL bytes is removed! ... the programmer to provide output character arrays big enough to hold ...
    (comp.lang.c)
  • Re: User Input issue
    ... now we know that the int data type uses 4 bytes of memory. ... You wrote a moment ago that the programmer does not ... covered strings yet (I'm a college freshman in a Programming I/Novice ...
    (comp.lang.c)
  • Re: PL/I string representations
    ... Mr Nilges is talking through his nose again. ... > machines that use ASCII. ... He liked large strings last year, ... example of a non-promotable programmer who's unfit for any role above ...
    (comp.programming)

Loading