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.
This commit is contained in:
Hiltjo Posthuma 2017-06-28 18:39:38 +02:00 committed by Laslo Hunhold
parent 5030846333
commit f5270aa241

View file

@ -176,6 +176,9 @@ getrequest(int fd, struct request *r)
ssize_t off; ssize_t off;
char h[HEADER_MAX], *p, *q; char h[HEADER_MAX], *p, *q;
/* empty all fields */
memset(r, 0, sizeof(*r));
/* /*
* receive header * receive header
*/ */
@ -264,11 +267,6 @@ getrequest(int fd, struct request *r)
* parse request-fields * parse request-fields
*/ */
/* empty all fields */
for (i = 0; i < NUM_REQ_FIELDS; i++) {
r->field[i][0] = '\0';
}
/* match field type */ /* match field type */
for (; *p != '\0';) { for (; *p != '\0';) {
for (i = 0; i < NUM_REQ_FIELDS; i++) { for (i = 0; i < NUM_REQ_FIELDS; i++) {