summaryrefslogtreecommitdiff
path: root/functions.c
diff options
context:
space:
mode:
authorLuke Bratch <luke@bratch.co.uk>2023-03-23 00:26:16 +0000
committerLuke Bratch <luke@bratch.co.uk>2023-03-23 00:26:16 +0000
commit85255291678e5cd6d42cdcd19ee413dc96191112 (patch)
tree8eb38ac1d9b36da165cf323f2c883b9de3c6799f /functions.c
parent7d12838e4c4d97cdd2757a8a7e00df41098e9a73 (diff)
Don't try to sockread() or socksend() if the file descriptor is NULL, assume all socksend() return values of <0 are errors, correct (currently unused) return values in sendtoserver().
Diffstat (limited to 'functions.c')
-rw-r--r--functions.c12
1 files changed, 6 insertions, 6 deletions
diff --git a/functions.c b/functions.c
index fcb1799..cd56904 100644
--- a/functions.c
+++ b/functions.c
@@ -476,7 +476,7 @@ int sendtoclient(int fd, char *strsrc, struct client *clients, struct settings *
}
debugprint(DEBUG_SOME, "sendtoclient(): sending \"%s\" (length %zd) to client with fd %d.\n", str, strlen(str), fd);
- if (socksend(clients[i].ssl, str, strlen(str), settings->clienttls) == -1) {
+ if (socksend(clients[i].ssl, str, strlen(str), settings->clienttls) < 0) {
debugprint(DEBUG_CRIT, "error: sendtoclient() socksend() error sending to client with fd '%d', errno '%d'.\n", fd, errno);
return 0;
}
@@ -545,7 +545,7 @@ int sendtoallclients(struct client *clients, char *strsrc, int except, struct se
continue;
}
debugprint(DEBUG_SOME, "sendtoallclients(): %s: sending '%s' to client with fd %d.\n", sendertype, str, clients[i].fd);
- if (socksend(clients[i].ssl, str, strlen(str), settings->clienttls) == -1) {
+ if (socksend(clients[i].ssl, str, strlen(str), settings->clienttls) < 0) {
debugprint(DEBUG_CRIT, "error: sendtoallclients() socksend() error sending to client with fd '%d', errno '%d'.\n", clients[i].fd, errno);
}
}
@@ -588,18 +588,18 @@ int sendtoserver(SSL *server_ssl, char *strsrc, int str_len, int clientfd, struc
// Found client in array, check authentication status
if (!clients[i].authed) {
debugprint(DEBUG_SOME, "sendtoserver(): skipping unauthenticated client with fd %d.\n", clients[i].fd);
- return 1;
+ return 0;
}
}
}
debugprint(DEBUG_SOME, "sendtoserver(): sending '%s' to IRC server (length %d).\n", str, str_len);
- if (socksend(server_ssl, str, str_len, settings->servertls) == -1) {
+ if (socksend(server_ssl, str, str_len, settings->servertls) < 0) {
debugprint(DEBUG_CRIT, "error: sendtoserver() socksend() error sending to server, errno '%d'.\n", clientfd, errno);
- return 1;
+ return 0;
}
- return 0;
+ return 1;
}
// Disconnect the client fd "fd" by close()ing it and remove