commit a0a2b864a69acca492e8e78ff2c246d37ed42346
parent 411705dfc04cf78985ab7532d8763747c24c7797
Author: FRIGN <dev@frign.de>
Date: Wed, 13 Aug 2014 21:05:53 +0200
Don't let r be uninitialized
Restore the functionality before the do-while-loop was removed.
Diffstat:
1 file changed, 7 insertions(+), 5 deletions(-)
diff --git a/quark.c b/quark.c
@@ -397,14 +397,16 @@ request(void) {
size_t offset = 0;
/* read request into reqbuf (MAXBUFLEN byte of reqbuf is emergency 0 terminator */
- for (; r > 0 && offset < MAXBUFLEN && (!strstr(reqbuf, "\r\n") || !strstr(reqbuf, "\n"));) {
- if ((r = read(req.fd, reqbuf + offset, MAXBUFLEN - offset)) == -1) {
- logerrmsg("error\tread: %s\n", strerror(errno));
- return -1;
- }
+ for (; (r = read(req.fd, reqbuf + offset, MAXBUFLEN - offset)) > 0 && offset < MAXBUFLEN
+ && (!strstr(reqbuf, "\r\n") || !strstr(reqbuf, "\n")); )
+ {
offset += r;
reqbuf[offset] = 0;
}
+ if (r == -1) {
+ logerrmsg("error\tread: %s\n", strerror(errno));
+ return -1;
+ }
/* extract host and mod */
if (getreqentry("Host:", reqhost, LENGTH(reqhost), " \t\r\n") != 0)