diff options
Diffstat (limited to 'src/server.cpp')
-rw-r--r-- | src/server.cpp | 25 |
1 files changed, 13 insertions, 12 deletions
diff --git a/src/server.cpp b/src/server.cpp index b5e5757..745b215 100644 --- a/src/server.cpp +++ b/src/server.cpp @@ -138,8 +138,8 @@ void DoServer(int port) { if (!((header.m_command == CONNECT) | (header.m_command == SENDF) |
(header.m_command == SENDF2) | (header.m_command == GETF))) {
- Log("[%s] WARNING: Unexpected initial connection command %s",
- NAME, com2str(header.m_command));
+ Log("[%s] WARN: Unexpected initial connection command %s", NAME,
+ com2str(header.m_command));
}
connStat[i].recInitHeader = true;
@@ -377,8 +377,7 @@ void doServerCommand(int i) { sendMessageToId(connStat[i].id, true, outHeader, message);
}
} else {
- Log("[---- : %s] Login failed: %s",
- com2str(header.m_command), username);
+ Log("[---- : %s] Login failed: %s", com2str(header.m_command), username);
outHeader.setFlags(S2C, FAIL, PUB, SIGN);
outHeader.m_command = LOGIN;
memcpy(outHeader.m_name, NAME, strlen(NAME));
@@ -515,11 +514,14 @@ void doServerCommand(int i) { offset += filenameLen;
buf2i(&buf[i][offset], fileLen);
offset += 4;
- // Log("[%s : %s] Saving file: %s", server_filename);
fp = fopen(FILE_DATABASE, "a");
- fputs(server_filename, fp);
- fputs("\n", fp);
- fclose(fp);
+ if (fp == NULL) {
+ Log("Failed to open %s for writing.", FILE_DATABASE);
+ } else {
+ fputs(server_filename, fp);
+ fputs("\n", fp);
+ fclose(fp);
+ }
buf2file(&buf[i][offset], fileLen, server_filename);
// Send SENDF/SENDF2 message to interested parties
@@ -630,15 +632,14 @@ void doServerCommand(int i) { if ((connStat[x].direction == C2S) &&
(connStat[x].linkType == MESSAGE_LINK) && (connStat[x].isLoggedIn)) {
strcat(message, "\n\t");
- strcat(message, connStat[x].name);
+ strncat(message, connStat[x].name, MAX_USERNAME_LEN);
}
}
outHeader.m_size = strlen(message);
sendMessageToId(connStat[i].id, false, outHeader, message);
break;
case PING:
- // Log("Ping from %s", header.m_name);
- asm("nop"); // do nothing
+ // PONG
break;
default:
Log("No doServerCommand() for command %s", com2str(header.m_command));
@@ -713,7 +714,7 @@ void prepareMessage(int i, Header header, char *message) { peers[i].events |= POLLWRNORM;
} else {
- Log("[%s] WARNING: attempted to write to C2S connection %d", NAME, i);
+ Log("[%s] WARN: attempted to write to C2S connection %d", NAME, i);
}
}
|