diff options
author | Markus Uhlin <markus@nifty-networks.net> | 2023-12-25 18:47:40 +0100 |
---|---|---|
committer | Markus Uhlin <markus@nifty-networks.net> | 2023-12-25 18:47:40 +0100 |
commit | 7290518df94259d2c8be1f929defb35f7125c156 (patch) | |
tree | faa9c9ee02de91ce6d8103fe1924027e509c44fb | |
parent | be62d05f7cfc4dc9a98c21aab1b280542917fe87 (diff) |
Improved pcommand()
-rw-r--r-- | FICS/utils.c | 38 |
1 files changed, 22 insertions, 16 deletions
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 |