From a9ff83947cf3bd70fc6fa9cca62c088c17e26a11 Mon Sep 17 00:00:00 2001 From: Markus Uhlin Date: Mon, 25 Dec 2023 18:33:42 +0100 Subject: Improved pprintf_prompt() --- FICS/utils.c | 25 +++++++++++-------------- 1 file changed, 11 insertions(+), 14 deletions(-) (limited to 'FICS') diff --git a/FICS/utils.c b/FICS/utils.c index 6cf0285..e8f4168 100644 --- a/FICS/utils.c +++ b/FICS/utils.c @@ -299,23 +299,20 @@ PUBLIC int psprintf_highlight(int p, char *s, char *format,...) return retval; } -PUBLIC int pprintf_prompt(int p, char *format,...) +PUBLIC int +pprintf_prompt(int p, char *format,...) { - char tmp[10 * MAX_LINE_SIZE]; /* Make sure you can handle 10 lines worth of - stuff */ - int retval; - va_list ap; + char tmp[10 * MAX_LINE_SIZE]; + int retval; + va_list ap; - va_start(ap, format); + va_start(ap, format); + retval = vsnprintf(tmp, sizeof tmp, format, ap); + va_end(ap); - retval = vsprintf(tmp, format, ap); - if (strlen(tmp) > 10 * MAX_LINE_SIZE) { - fprintf(stderr, "FICS: pprintf_prompt buffer overflow\n"); - } - net_send_string(parray[p].socket, tmp, 1); - net_send_string(parray[p].socket, parray[p].prompt, 1); - va_end(ap); - return retval; + net_send_string(parray[p].socket, tmp, 1); + net_send_string(parray[p].socket, parray[p].prompt, 1); + return retval; } PUBLIC int -- cgit v1.2.3