summary refs log tree commit diff
diff options
context:
space:
mode:
authorJune McEnroe <june@causal.agency>2020-08-06 13:38:52 -0400
committerJune McEnroe <june@causal.agency>2020-08-06 13:38:52 -0400
commit4046ddacddced524615f8314d6389b971843d9b9 (patch)
treec05334433a888089033d51d31640618f1bfce892
parentDocument concatenating client certificates for auth (diff)
downloadpounce-4046ddacddced524615f8314d6389b971843d9b9.tar.gz
pounce-4046ddacddced524615f8314d6389b971843d9b9.zip
Handle broken clients sending only \n
Sigh. The robustness principle enables the proliferation of worse
quality software.
-rw-r--r--client.c17
1 files changed, 9 insertions, 8 deletions
diff --git a/client.c b/client.c
index 4f315c8..30174e9 100644
--- a/client.c
+++ b/client.c
@@ -358,21 +358,22 @@ void clientRecv(struct Client *client) {
 	}
 	client->len += read;
 
-	char *crlf;
+	char *lf;
 	char *line = client->buf;
 	for (;;) {
-		crlf = memmem(line, &client->buf[client->len] - line, "\r\n", 2);
-		if (!crlf) break;
+		lf = memchr(line, '\n', &client->buf[client->len] - line);
+		if (!lf) break;
 		if (verbose) {
-			fprintf(stderr, "\x1B[33m%.*s\x1B[m\n", (int)(crlf - line), line);
+			fprintf(stderr, "\x1B[33m%.*s\x1B[m\n", (int)(lf - line), line);
 		}
-		if (client->need || intercept(line, crlf - line)) {
-			crlf[0] = '\0';
+		if (client->need || intercept(line, lf - line)) {
+			lf[0] = '\0';
+			if (lf - line && lf[-1] == '\r') lf[-1] = '\0';
 			clientParse(client, line);
 		} else {
-			serverSend(line, crlf + 2 - line);
+			serverSend(line, lf + 1 - line);
 		}
-		line = crlf + 2;
+		line = lf + 1;
 	}
 	client->len -= line - client->buf;
 	memmove(client->buf, line, client->len);
2020-11-24Update libretls to 3.3.0June McEnroe 2020-11-17Update catgirl to 1.3June McEnroe 2020-11-17Update libretls to 3.2.2June McEnroe 2020-09-29Update libretls to 3.2.1June McEnroe 2020-09-10Update catgirl to 1.2June McEnroe 2020-09-09Add pounce-palaver portJune McEnroe 2020-09-09Update pounce to 2.0June McEnroe 2020-09-09Update litterbox to 1.6June McEnroe 2020-08-23Add scooper portJune McEnroe 2020-08-23Add catsit portJune McEnroe 2020-08-13Update pounce to 1.4p2June McEnroe 2020-08-11Update pounce to 1.4p1June McEnroe 2020-08-10Add litterbox portJune McEnroe 2020-08-10Add missing USES=pkgconfig to pounceJune McEnroe