Fix off-by-one

This commit is contained in:
sin 2014-08-21 22:46:38 +01:00 committed by FRIGN
parent 5dac8de322
commit 293eb4489d

View file

@ -444,8 +444,8 @@ request(void) {
ssize_t r;
size_t offset = 0;
/* read request into reqbuf (MAXBUFLEN byte of reqbuf is emergency 0 terminator */
for (; (r = read(req.fd, reqbuf + offset, MAXBUFLEN - offset)) > 0 && offset < MAXBUFLEN
/* read request into reqbuf (MAXBUFLEN byte of reqbuf is emergency 0 terminator) */
for (; (r = read(req.fd, reqbuf + offset, MAXBUFLEN - offset - 1)) > 0 && offset < MAXBUFLEN
&& !strstr(reqbuf, "\r\n\r\n") && !strstr(reqbuf, "\n\n"); )
{
offset += r;