[mw-devel] MW3 r1274 - trunk/src/server
arthur at sucs.org
arthur at sucs.org
Tue Nov 6 16:00:20 GMT 2012
Author: arthur
Date: 2012-11-06 16:00:19 +0000 (Tue, 06 Nov 2012)
New Revision: 1274
Modified:
trunk/src/server/mwserv.c
trunk/src/server/servsock.c
Log:
wipe who list on server start
Modified: trunk/src/server/mwserv.c
===================================================================
--- trunk/src/server/mwserv.c 2012-11-06 15:45:17 UTC (rev 1273)
+++ trunk/src/server/mwserv.c 2012-11-06 16:00:19 UTC (rev 1274)
@@ -6,6 +6,7 @@
#include <inttypes.h>
#include "../socket.h"
#include "servsock.h"
+#include "../files.h"
/* unused, but necessary to link other util functions */
int idle = 0;
@@ -81,6 +82,10 @@
init_server();
+ /* at server start nobody is logged in, wipe who list */
+ int fd = openwhofile(O_TRUNC|O_WRONLY);
+ close(fd);
+
mainsock = open_mainsock(opts.port);
if (mainsock < 0) {
Modified: trunk/src/server/servsock.c
===================================================================
--- trunk/src/server/servsock.c 2012-11-06 15:45:17 UTC (rev 1273)
+++ trunk/src/server/servsock.c 2012-11-06 16:00:19 UTC (rev 1274)
@@ -229,6 +229,12 @@
/* client just told us who they are */
if (msg->head.type == FOURCC("HELO")) {
memcpy(&conn->addr, &msg->head.src, sizeof(conn->addr));
+ if (msg->bodylen != 4) {
+ printf("Invalid HELO from fd=%d. dropping.\n", conn->fd);
+ ipcmsg_destroy(msg);
+ drop_connection(conn);
+ return;
+ }
memcpy(&conn->user, msg->body, sizeof(conn->user));
printf("WHO Add: pid=%d posn=%d\n", conn->addr, conn->user);
who_add(conn->addr, conn->user);
More information about the mw-devel
mailing list