Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

strcpy causing segfaults from source

Name: Anonymous 2010-08-12 14:42

A snippet in my code goes something like

puts(string1);
strcpy(string2, string1);
puts(string1);

but that 2nd call of puts results in a segfault. I thought strcpy only copies. wtf is going on? I couldn't recreate it though on its own so I think it must be this project.

If you guys have nothing to do, maybe you can have a look.
http://pastebin.ca/1915922
It's part of a larger project but this one here reads two lines of text from a given file and separates the tokens that are separated by commas and spaces.

Name: Anonymous 2010-08-12 20:48

You're using fixed size buffers, but not making sure that unknown input fits inside them. Don't do that. Use snprintf instead of strcpy, then you at least truncate overly long input instead of overflowing buffers.

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List