2004-05-21 Stefan Jones <stefan.jones@multigig.com>

* src/frontend/terminal.c:
    Fix buffer overflow in out_printf
This commit is contained in:
stefanjones 2004-05-21 20:08:12 +00:00
parent 596a434652
commit 66cf87899f
2 changed files with 17 additions and 2 deletions

View File

@ -1,3 +1,8 @@
2004-05-21 Stefan Jones <stefan.jones@multigig.com>
* src/frontend/terminal.c:
Fix buffer overflow in out_printf
2004-05-19 Stefan Jones <stefan.jones@multigig.com>
* src/tclspice.c:

View File

@ -240,11 +240,21 @@ out_send(char *string)
void
out_printf(char *fmt, char *s1, char *s2, char *s3, char *s4, char *s5, char *s6, char *s7, char *s8, char *s9, char *s10)
{
char buf[MAXLEN];
char _buf[MAXLEN];
char *buf=_buf;
int len;
sprintf(buf, fmt, s1, s2, s3, s4, s5, s6, s7, s8, s9, s10);
len = snprintf(buf, MAXLEN, fmt, s1, s2, s3, s4, s5, s6, s7, s8, s9, s10);
if(len >= MAXLEN) {
buf = MALLOC(len+1);
sprintf(buf, fmt, s1, s2, s3, s4, s5, s6, s7, s8, s9, s10);
}
out_send(buf);
if(len >= MAXLEN)
FREE(buf);
return;
}