Wed May 6 17:42:48 EST 2009 quozl at us.netrek.org * add client name to version packet and log Client normally identifies to server using a CP_MESSAGE on first SP_PICKOK, but with a version number only. This was used with RSA on clients that did not support feature packets, and had no other use. This change prints the whole version message to the ERRORS log, for statistical analysis later. Clients are encouraged to send "@name version", any number of spaces are permitted, but the last word will be taken as the version number of the client. Also fixed a valgrind detected failure to free a heap pointer. --- old-netrek-server/Vanilla/ntserv/socket.c 2009-05-06 17:48:30.000000000 +1000 +++ new-netrek-server/Vanilla/ntserv/socket.c 2009-05-06 17:48:30.000000000 +1000 @@ -127,7 +127,7 @@ static void handlePingResponse(struct ping_cpacket *packet); #endif -static int clientVersion(struct mesg_spacket *packet); +static void clientVersion(struct mesg_spacket *packet); static int doRead(int asock); static int gwrite(int fd, char *wbuf, size_t size); static void logmessage(char *string); @@ -2011,17 +2011,23 @@ } } -static int clientVersion(struct mesg_spacket *packet) +static void clientVersionFree() { - - if (packet->mesg[0] != '@') - return FALSE; - - /* FIXME: never freed */ - version = (char *)strdup(INDEX(packet->mesg,'@')+1); - return TRUE; + if (version == NULL) return; + free(version); + version = NULL; } +static void clientVersion(struct mesg_spacket *packet) +{ + char *mesg = packet->mesg; + if (*mesg == '@') { + mesg++; + atexit(clientVersionFree); + version = strdup(mesg); + ERROR(1,("%s: version %s\n", whoami(), version)); + } +} #ifdef RSA