summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLuke Bratch <luke@bratch.co.uk>2019-07-18 18:39:32 +0100
committerLuke Bratch <luke@bratch.co.uk>2019-07-18 18:39:32 +0100
commit40a9f76e2d4ddd972b2e9ea2594c7567718517f4 (patch)
tree9eb2bcee60e581fd64977a3399f8fe08e2c2a78f
parentb98da7cb52a0b6969ff43c921ea40ce4270e5736 (diff)
Only check for newlines at the end of client strings if the string length is at least one.
-rw-r--r--TODO6
-rw-r--r--blabouncer.c7
2 files changed, 11 insertions, 2 deletions
diff --git a/TODO b/TODO
index e60ebb9..966ba41 100644
--- a/TODO
+++ b/TODO
@@ -1 +1,7 @@
Fuzzing.
+
+"/me" PRIVMSGs are not logged or replayed correctly.
+
+Fix warnings with different compilers (older gcc, clang).
+
+Support multiple connect commands.
diff --git a/blabouncer.c b/blabouncer.c
index ddcd07f..119e725 100644
--- a/blabouncer.c
+++ b/blabouncer.c
@@ -825,8 +825,11 @@ void dochat(int *serversockfd, int *clientsockfd, struct settings *settings) {
// null terminate that baby
clientbuf[clientnumbytes] = '\0'; // TODO make sure this can't overrun if some super long line (max bytes?) was received
// clear up any newlines - TODO - Should we be doing this? If not, we can stop only doing truncation checks for the server in processrawstring().
- while (clientbuf[strlen(clientbuf) - 1] == '\n' || clientbuf[strlen(clientbuf) - 1] == '\r') {
- clientbuf[strlen(clientbuf) - 1] = '\0';
+ // Only check for newlines if the string length is at least one!
+ if (strlen(clientbuf) > 0) {
+ while (clientbuf[strlen(clientbuf) - 1] == '\n' || clientbuf[strlen(clientbuf) - 1] == '\r') {
+ clientbuf[strlen(clientbuf) - 1] = '\0';
+ }
}
debugprint(DEBUG_SOME, "BOUNCER-CLIENT RECEIVED: '%s'\n", clientbuf);