diff options
author | Markus Uhlin <markus@nifty-networks.net> | 2023-12-25 18:44:48 +0100 |
---|---|---|
committer | Markus Uhlin <markus@nifty-networks.net> | 2023-12-25 18:44:48 +0100 |
commit | be62d05f7cfc4dc9a98c21aab1b280542917fe87 (patch) | |
tree | 9a210a02b6b2d1ce1555ddf8ddf077a3f11560a7 /FICS/utils.c | |
parent | 3c4980ed82df11752379ae10fc2bb97590af187f (diff) |
Improved pprintf()
Diffstat (limited to 'FICS/utils.c')
-rw-r--r-- | FICS/utils.c | 24 |
1 files changed, 11 insertions, 13 deletions
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 |