From be62d05f7cfc4dc9a98c21aab1b280542917fe87 Mon Sep 17 00:00:00 2001 From: Markus Uhlin Date: Mon, 25 Dec 2023 18:44:48 +0100 Subject: Improved pprintf() --- FICS/utils.c | 24 +++++++++++------------- 1 file changed, 11 insertions(+), 13 deletions(-) (limited to 'FICS/utils.c') diff --git a/FICS/utils.c b/FICS/utils.c index 284eefb..3d53afc 100644 --- a/FICS/utils.c +++ b/FICS/utils.c @@ -221,21 +221,19 @@ PUBLIC int pcommand(int p, char *comstr, ...) return retval; } -PUBLIC int pprintf(int p, char *format, ...) +PUBLIC int +pprintf(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; - va_start(ap, format); + char tmp[10 * MAX_LINE_SIZE]; + int retval; + va_list ap; - retval = vsprintf(tmp, format, ap); - if (strlen(tmp) > 10 * MAX_LINE_SIZE) { - fprintf(stderr, "FICS: pprintf buffer overflow\n"); - } - net_send_string(parray[p].socket, tmp, 1); - va_end(ap); - return retval; + va_start(ap, format); + retval = vsnprintf(tmp, sizeof tmp, format, ap); + va_end(ap); + + net_send_string(parray[p].socket, tmp, 1); + return retval; } PUBLIC void -- cgit v1.2.3