From 0d3847aae56674ede8b089389ebdc544fff2a932 Mon Sep 17 00:00:00 2001 From: dwarning Date: Tue, 11 Sep 2007 20:27:10 +0000 Subject: [PATCH] prevent crash at long messages in out_printf --- src/frontend/terminal.c | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/src/frontend/terminal.c b/src/frontend/terminal.c index c6e758c29..d70cdad22 100644 --- a/src/frontend/terminal.c +++ b/src/frontend/terminal.c @@ -243,11 +243,20 @@ 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) { +#if defined(HAVE_ASPRINTF) + char * buf; + asprintf(&buf, fmt, s1, s2, s3, s4, s5, s6, s7, s8, s9, s10); + out_send(buf); + FREE(buf); +#elif defined(HAVE_SNPRINTF) + char buf[MAXLEN]; + snprintf(buf, MAXLEN, fmt, s1, s2, s3, s4, s5, s6, s7, s8, s9, s10); + out_send(buf); +#else /* guaranteed a bug for long messages */ char buf[MAXLEN]; - sprintf(buf, fmt, s1, s2, s3, s4, s5, s6, s7, s8, s9, s10); - out_send(buf); +#endif return; }