aboutsummaryrefslogtreecommitdiffstats
path: root/FICS/network.c
diff options
context:
space:
mode:
authorMarkus Uhlin <markus@nifty-networks.net>2024-07-06 19:04:01 +0200
committerMarkus Uhlin <markus@nifty-networks.net>2024-07-06 19:04:01 +0200
commit0e3529e3b5c6c2383226f271e51ab50d990b0a1b (patch)
tree2373d90c5fe8a62f003d773f11cdcc391623349f /FICS/network.c
parentf5aad8fe893db67bdbd641d001d8e5d4792f693b (diff)
Added a new type and replaced sprintf() calls with msnprintf()
Diffstat (limited to 'FICS/network.c')
-rw-r--r--FICS/network.c19
1 files changed, 11 insertions, 8 deletions
diff --git a/FICS/network.c b/FICS/network.c
index 29c0041..41db477 100644
--- a/FICS/network.c
+++ b/FICS/network.c
@@ -15,6 +15,7 @@
#include "common.h"
#include "config.h"
#include "ficsmain.h"
+#include "maxxes-utils.h"
#include "network.h"
#include "playerdb.h"
#include "rmalloc.h"
@@ -328,7 +329,7 @@ net_send_string(int fd, char *str, int format)
* C) if some error, return -1.
*/
PUBLIC int
-readline2(char *com, int who)
+readline2(comstr_t *cs, int who)
{
int howmany, state, fd, pending;
unsigned char *start, *s, *d;
@@ -378,7 +379,8 @@ readline2(char *com, int who)
state = 1;
} else if (*s == '\n') {
*s = '\0';
- sprintf(com, "%s", start);
+ msnprintf(cs->com, ARRAY_SIZE(cs->com), "%s",
+ start);
if (howmany)
bcopy(s + 1, start, howmany);
con[who].state = 0;
@@ -416,7 +418,8 @@ readline2(char *com, int who)
state = 1;
else if (*s == '\n') {
*d = '\0';
- sprintf(com, "%s", start);
+ msnprintf(cs->com, ARRAY_SIZE(cs->com), "%s",
+ start);
if (howmany)
memmove(start, s + 1, howmany);
con[who].state = 0;
@@ -454,7 +457,7 @@ readline2(char *com, int who)
if (con[who].numPending == MAX_STRING_LENGTH - 1) { // buffer full
*d = '\0';
- sprintf(com, "%s", start);
+ msnprintf(cs->com, ARRAY_SIZE(cs->com), "%s", start);
con[who].state = 0;
con[who].numPending = 0;
con[who].processed = 0;
@@ -574,7 +577,7 @@ net_connected_host(int fd)
}
PUBLIC void
-ngc2(char *com, int timeout)
+ngc2(comstr_t *cs, int timeout)
{
fd_set readfds;
int fd, loop, nfound, lineComplete;
@@ -617,17 +620,17 @@ ngc2(char *com, int timeout)
if (con[loop].status != NETSTAT_EMPTY) {
fd = con[loop].fd;
- if ((lineComplete = readline2(com, fd)) == 0) {
+ if ((lineComplete = readline2(cs, fd)) == 0) {
// partial line: do nothing
continue;
}
if (lineComplete > 0) { // complete line: process it
#ifdef TIMESEAL
- if (!parseInput(com, &con[loop]))
+ if (!parseInput(cs->com, &con[loop]))
continue;
#endif
- if (process_input(fd, com) != COM_LOGOUT) {
+ if (process_input(fd, cs->com) != COM_LOGOUT) {
net_flush_connection(fd);
continue;
}