From 7290518df94259d2c8be1f929defb35f7125c156 Mon Sep 17 00:00:00 2001 From: Markus Uhlin Date: Mon, 25 Dec 2023 18:47:40 +0100 Subject: Improved pcommand() --- FICS/utils.c | 38 ++++++++++++++++++++++---------------- 1 file changed, 22 insertions(+), 16 deletions(-) (limited to 'FICS') diff --git a/FICS/utils.c b/FICS/utils.c index 3d53afc..c23acac 100644 --- a/FICS/utils.c +++ b/FICS/utils.c @@ -202,23 +202,29 @@ PUBLIC int mail_file_to_user(int p, char *subj, char *fname) } -/* Process a command for a user */ -PUBLIC int pcommand(int p, char *comstr, ...) +/* + * Process a command for a user + */ +PUBLIC int +pcommand(int p, char *comstr, ...) { - char tmp[MAX_LINE_SIZE]; - int retval; - int current_socket = parray[p].socket; - va_list ap; - va_start(ap, comstr); - - vsprintf(tmp, comstr, ap); - retval = process_input(current_socket, tmp); - if (retval == COM_LOGOUT) { - process_disconnection(current_socket); - net_close_connection(current_socket); - } - va_end(ap); - return retval; + char tmp[MAX_LINE_SIZE]; + int current_socket = parray[p].socket; + int retval; + va_list ap; + + va_start(ap, comstr); + vsnprintf(tmp, sizeof tmp, comstr, ap); + va_end(ap); + + retval = process_input(current_socket, tmp); + + if (retval == COM_LOGOUT) { + process_disconnection(current_socket); + net_close_connection(current_socket); + } + + return retval; } PUBLIC int -- cgit v1.2.3