aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--src/client.cpp4
-rw-r--r--src/server.cpp25
2 files changed, 15 insertions, 14 deletions
diff --git a/src/client.cpp b/src/client.cpp
index baf2215..d2b7562 100644
--- a/src/client.cpp
+++ b/src/client.cpp
@@ -486,10 +486,10 @@ void doClientCommand(int i) {
// Open new S2C connection with server for file transfer
fd = socket(AF_INET, SOCK_STREAM, 0);
if (fd == -1)
- Log("[%s] Warning: Cannot create file transfer socket.", NAME);
+ Log("[%s] WARN: Cannot create file transfer socket.", NAME);
else if (connect(fd, (const struct sockaddr *)&serverAddr,
sizeof(serverAddr)) != 0)
- Log("[%s] Warning: File transfer cannot connect to server", NAME);
+ Log("[%s] WARN: File transfer cannot connect to server", NAME);
else {
// Usual setup
SetNonBlockIO(fd);
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);
}
}