Buffer overflow cause by no null terminator

S

semut

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.
 
V

Victor Bazarov

semut said:
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
 
S

Salt_Peter

semut said:
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.
 
B

Binary

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
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,744
Messages
2,569,483
Members
44,902
Latest member
Elena68X5

Latest Threads

Top