Re: Are bad developer libraries the problem with M$ software?

From: Frank Knobbe (fknobbe@knobbeits.com)
Date: 11/22/02

  • Next message: Glynn Clements: "Re: Are bad developer libraries the problem with M$ software?"
    From: Frank Knobbe <fknobbe@knobbeits.com>
    To: Andrew Dalgleish <secprog@andrewdalgleish.dyndns.org>
    Date: 22 Nov 2002 09:31:48 -0600
    

    On Tue, 2002-11-19 at 16:57, Andrew Dalgleish wrote:

    > No, it would not. strncpy does NOT append the trailing 0 if the
    > length of the source is greater than or equal to the count.
    >
    > Using sizeof(dst)-1 will leave the last byte in the buffer unchanged.
    > If dst is on the stack there is no guarantee the string is terminated.
    > To be sure, you would *also* need to add
    > dst[sizeof(dst)-1] = 0;
    >
    > C'mon people, this really is beginner stuff.
    > Please RTFM before you post well-meaning advice.
    >
    > You might also like to look at the bsd-style strlcpy/strlcat functions.

    Andrew,

    I'm fully aware of that, and I have rtfm some years back. My comment was
    about the size definition.

    While you have the red pen in your hand, you might also want to point
    out that I considered the terminating null a single byte in the example
    of the wide character string functions. I don't use wide chars in my
    programs so I don't know if it's a single or double 0. But hey, while
    we're listing mistakes...

    It is sad to see how one gets chastised about typos and conceptual ideas
    (as opposed to list debugged code)...

    Frank