Buffer overflow cause by no null terminator

Discussion in 'C++' started by semut, Dec 1, 2006.

  1. semut

    semut Guest

    Hi,

    Just like to find out are there a set of proven methods that can
    effectively prevent buffer overflow occur cause by non null terminator
    string.

    thanks.
     
    semut, Dec 1, 2006
    #1
    1. Advertising

  2. semut wrote:
    > Just like to find out are there a set of proven methods that can
    > effectively prevent buffer overflow occur cause by non null terminator
    > string.


    I know only one: do not use plain char arrays for your "strings".
    Use std::string instead.

    V
    --
    Please remove capital 'A's when replying by e-mail
    I do not respond to top-posted replies, please don't ask
     
    Victor Bazarov, Dec 1, 2006
    #2
    1. Advertising

  3. semut

    Salt_Peter Guest

    semut wrote:
    > Hi,
    >
    > Just like to find out are there a set of proven methods that can
    > effectively prevent buffer overflow occur cause by non null terminator
    > string.
    >
    > thanks.


    Yes: don't use a null-terminated string. Use a std::string instead.
     
    Salt_Peter, Dec 1, 2006
    #3
  4. semut

    Binary Guest

    On Dec 1, 11:32 am, "semut" <> wrote:
    > Hi,
    >
    > Just like to find out are there a set of proven methods that can
    > effectively prevent buffer overflow occur cause by non null terminator
    > string.


    use strncpy instead of strcpy

    >
    > thanks.
     
    Binary, Dec 1, 2006
    #4
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Mack Attack
    Replies:
    3
    Views:
    6,942
    Roedy Green
    Aug 8, 2003
  2. Alexander Malkis
    Replies:
    10
    Views:
    914
  3. David Hirschfield

    Help: asyncore/asynchat and terminator string

    David Hirschfield, Jan 16, 2007, in forum: Python
    Replies:
    0
    Views:
    333
    David Hirschfield
    Jan 16, 2007
  4. dbtouch
    Replies:
    32
    Views:
    3,280
    Jerry Coffin
    Mar 8, 2009
  5. tntelle

    delete end character / null terminator ?

    tntelle, Aug 18, 2009, in forum: C Programming
    Replies:
    6
    Views:
    983
Loading...

Share This Page