summaryrefslogtreecommitdiff
path: root/blabouncer.c
diff options
context:
space:
mode:
Diffstat (limited to 'blabouncer.c')
-rw-r--r--blabouncer.c7
1 files changed, 5 insertions, 2 deletions
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);