diff options
author | Christian Grothoff <christian@grothoff.org> | 2007-06-13 23:09:25 +0000 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2007-06-13 23:09:25 +0000 |
commit | 6e12c7fae2b6350a65f1b2eeedafd6f05510726b (patch) | |
tree | 08a9904906bb81e36e454db6ceb28878bc18252f | |
parent | 7020eed03e0c270399c0a9087815cbbc93dda15f (diff) |
fix
-rw-r--r-- | src/daemon/session.c | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/src/daemon/session.c b/src/daemon/session.c index 8854b94b..e3aa1241 100644 --- a/src/daemon/session.c +++ b/src/daemon/session.c @@ -158,6 +158,8 @@ MHD_get_next_header_line(struct MHD_Session * session) { size_t pos; size_t start; + if (session->readLoc == 0) + return NULL; start = 0; pos = 0; rbuf = session->read_buffer; @@ -189,11 +191,11 @@ MHD_get_next_header_line(struct MHD_Session * session) { return NULL; } /* found, check if we have proper CRLF */ - rbuf = malloc(pos); + rbuf = malloc(pos + 1); memcpy(rbuf, session->read_buffer, - pos-1); - rbuf[pos-1] = '\0'; + pos); + rbuf[pos] = '\0'; if ( (session->read_buffer[pos] == '\r') && (session->read_buffer[pos+1] == '\n') ) pos++; /* skip both r and n */ |