commit f5270aa24148c00b73796b6c7c654c2caaeeb577
parent 5030846333f769f13581ae7d57b1f913c3f384a2
Author: Hiltjo Posthuma <hiltjo@codemadness.org>
Date: Wed, 28 Jun 2017 18:39:38 +0200
initialize request fields used as output in log
this could crash quark or print gibberish if the connection is closed
before parsing these fields: r->target is uninitialized, but printed
in the log.
Diffstat:
1 file changed, 3 insertions(+), 5 deletions(-)
diff --git a/quark.c b/quark.c
@@ -176,6 +176,9 @@ getrequest(int fd, struct request *r)
ssize_t off;
char h[HEADER_MAX], *p, *q;
+ /* empty all fields */
+ memset(r, 0, sizeof(*r));
+
/*
* receive header
*/
@@ -264,11 +267,6 @@ getrequest(int fd, struct request *r)
* parse request-fields
*/
- /* empty all fields */
- for (i = 0; i < NUM_REQ_FIELDS; i++) {
- r->field[i][0] = '\0';
- }
-
/* match field type */
for (; *p != '\0';) {
for (i = 0; i < NUM_REQ_FIELDS; i++) {