End of headers not detected if they come in more than one read() #4

Closed
ghost opened this Issue Jun 22, 2012 · 0 comments

Comments

Projects
None yet
1 participant
@ghost

ghost commented Jun 22, 2012

Steps to reproduce: attempt to GET something via telnet.

Patch:

diff --git src/core.c src/core.c
index 7a4271d..bfab215 100644
--- src/core.c
+++ src/core.c
@@ -811,8 +811,8 @@ static int ws_body_slice(ws_request_t *req, int size) {

 static int ws_head_slice(ws_request_t *req, int size) {
     req->bufposition += size;
-    char *e1 = memmem(req->headers_buf, size, "\r\n\r\n", 4);
-    char *e2 = memmem(req->headers_buf, size, "\n\n", 2);
+    char *e1 = memmem(req->headers_buf, req->bufposition, "\r\n\r\n", 4);
+    char *e2 = memmem(req->headers_buf, req->bufposition, "\n\n", 2);
     size_t reallen;
     if(e2 < e1 && e2 || !e1) {
         e1 = e2;

tailhook closed this in 2bc44a0 Jun 25, 2012

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment