A more liberal input string handling. - geomyidae - A small C-based gopherd. HTML git clone git://bitreich.org/geomyidae/ git://enlrupgkhuxnvlhsf6lc3fziv5h2hhfrinws65d7roiv6bfj7d652fid.onion/geomyidae/ DIR Log DIR Files DIR Refs DIR Tags DIR README DIR LICENSE --- DIR commit 15637a95cdfd6cda10f147ad8cfb56ae16a4abea DIR parent b3b6d54e4122244a89b50987b122a135b6b40586 HTML Author: Christoph Lohmann <20h@r-36.net> Date: Sat, 12 May 2012 09:12:40 +0200 A more liberal input string handling. Diffstat: M main.c | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) --- DIR 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)) {