commit 15637a95cdfd6cda10f147ad8cfb56ae16a4abea
parent b3b6d54e4122244a89b50987b122a135b6b40586
Author: Christoph Lohmann <20h@r-36.net>
Date: Sat, 12 May 2012 09:12:40 +0200
A more liberal input string handling.
Diffstat:
1 file changed, 9 insertions(+), 6 deletions(-)
diff --git a/main.c b/main.c
@@ -140,12 +140,15 @@ handlerequest(int sock, char *base, char *ohost, char *port, char *clienth,
args = nil;
len = recv(sock, recvb, sizeof(recvb)-1, 0);
- if(len > 0) {
- if(recvb[len - 2] == '\r')
- recvb[len - 2] = '\0';
- if(recvb[len - 1] == '\n')
- recvb[len - 1] = '\0';
- }
+ if (len <= 0)
+ return;
+
+ c = strchr(recvb, '\r');
+ if(c)
+ c[0] = '\0';
+ c = strchr(recvb, '\n');
+ if(c)
+ c[0] = '\0';
memmove(recvc, recvb, len+1);
if(!strncmp(recvb, "URL:", 4)) {