Don't let r be uninitialized
Restore the functionality before the do-while-loop was removed.
This commit is contained in:
parent
411705dfc0
commit
a0a2b864a6
1 changed files with 7 additions and 5 deletions
12
quark.c
12
quark.c
|
@ -397,14 +397,16 @@ request(void) {
|
||||||
size_t offset = 0;
|
size_t offset = 0;
|
||||||
|
|
||||||
/* read request into reqbuf (MAXBUFLEN byte of reqbuf is emergency 0 terminator */
|
/* read request into reqbuf (MAXBUFLEN byte of reqbuf is emergency 0 terminator */
|
||||||
for (; r > 0 && offset < MAXBUFLEN && (!strstr(reqbuf, "\r\n") || !strstr(reqbuf, "\n"));) {
|
for (; (r = read(req.fd, reqbuf + offset, MAXBUFLEN - offset)) > 0 && offset < MAXBUFLEN
|
||||||
if ((r = read(req.fd, reqbuf + offset, MAXBUFLEN - offset)) == -1) {
|
&& (!strstr(reqbuf, "\r\n") || !strstr(reqbuf, "\n")); )
|
||||||
logerrmsg("error\tread: %s\n", strerror(errno));
|
{
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
offset += r;
|
offset += r;
|
||||||
reqbuf[offset] = 0;
|
reqbuf[offset] = 0;
|
||||||
}
|
}
|
||||||
|
if (r == -1) {
|
||||||
|
logerrmsg("error\tread: %s\n", strerror(errno));
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
/* extract host and mod */
|
/* extract host and mod */
|
||||||
if (getreqentry("Host:", reqhost, LENGTH(reqhost), " \t\r\n") != 0)
|
if (getreqentry("Host:", reqhost, LENGTH(reqhost), " \t\r\n") != 0)
|
||||||
|
|
Loading…
Reference in a new issue