Re: [Full-Disclosure] C99 Security Alert-Old-New-Who-Cares :) - (:

Valdis.Kletnieks_at_vt.edu
Date: 05/30/03

  • Next message: Schmehl, Paul L: "RE: [Full-Disclosure] C99 Security Alert-Old-New-Who-Cares :) - (:"
    To: "democow ...." <democow8086@hotmail.com>
    Date: Fri, 30 May 2003 11:41:38 -0400
    

    On Fri, 30 May 2003 04:05:32 -0000, "democow ...." <democow8086@hotmail.com> said:

    > char * strcpy(char * dest,const char *src)
    > {
    > char *tmp = dest;
    >
    > [1] while ((*dest++ = *src++) != '\0')
    > /* nothing */;
    > return tmp;
    > }

    Kernighan & Ritchie, "The C Programming Language", had this in the first
    edition - and correctly noted that this can be further optimized to:

                 while (*dest++ = *src++);

    eliminating a comparison to '\0'. So not only is it insecure, but it's
    inefficient, unless you have a *really* good optimizing compiler that can
    tell that the comparison to null can be optimized away. And yes, you
    need a *good* optimizer that can see that comparing to a null byte is
    a special case (for instance, you can't optimize != '\n' the same way).

    
    

    _______________________________________________
    Full-Disclosure - We believe in it.
    Charter: http://lists.netsys.com/full-disclosure-charter.html



  • Next message: Schmehl, Paul L: "RE: [Full-Disclosure] C99 Security Alert-Old-New-Who-Cares :) - (:"

    Relevant Pages

    • Re: Personal Rexx (Quercus) or what?
      ... FWIW, http://hobbes.nmsu.edu/pub/os2/dev/rexx/rexxtacy.zip ... At least the main part of the generated code should be portable somehow. ... Optimizing it is more difficult, you may want some RXSTRING's ... another programming language probably won't make your apps fly w.r.t. ...
      (comp.lang.rexx)
    • Re: help me learn C
      ... The C Programming Language, 2nd Ed. Kernighan & Ritchie. ... Prentice Hall, ...
      (comp.lang.c)
    • Re: beginner c questions
      ... "The C Programming Language" Second Edition. ... I actually have Kernighan and Ritchie, "The C Programming Language" ...
      (comp.lang.c)
    • Re: comp.lang.c
      ... dravid wrote: ... I suggest The C Programming Language" by Kernighan and Ritchie - ISBN 0-13-110362-8 ...
      (comp.lang.c)
    • Re: TUTORIAL
      ... Buy "The C Programming Language", by Kernighan & Ritchie. ... Posted via a free Usenet account from http://www.teranews.com ...
      (comp.lang.c)