[Kaffe] could this buffer overflow?

Moses DeJong dejong at cs.umn.edu
Fri Feb 5 13:24:40 PST 1999


I was looking at some code in stackTrace.c in the function
printStackTrace() when I noticed this.


char buf[200];

...

sprintf(buf, "\tat %.80s.%.80s(%s:%d)",
    CLASS_CNAME(meth->class),
    meth->name->data,
    CLASS_SOURCEFILE(meth->class),
    linenr);

Is it just me or does it seem like this buffer could overflow if
the CLASS_SOURCEFILE name is longer than 30 chars?


Why not use snprintf so?


snprintf(buff, 200, ...



Mo DeJong
dejong at cs.umn.edu



More information about the kaffe mailing list