Reply to post: sscanf .... sh*t scan fail!

You've seen things people wouldn't believe – so tell us your programming horrors

menne386

sscanf .... sh*t scan fail!

Some C-style text parsing code that i incorrectly tried to protect against overruns...

(In a c++ project...)

char tc=' ';

int size=0;

if(sscanf(buf," frame %20d %20c",sizeof(buf),&size,&tc)==2 && tc=='{') {

//Code to parse a frame

}

I am accidentally reading 20 chars into a single allocated char here... Messed up my stack enough to bypass all of my regular crash handling... seriously... stack-traces don't tell you sh*t in this case...

POST COMMENT House rules

Not a member of The Register? Create a new account here.

  • Enter your comment

  • Add an icon

Anonymous cowards cannot choose their icon