[hackers] [quark] initialize request fields used as output in log || Hiltjo Posthuma

From: <git_AT_suckless.org>
Date: Wed, 28 Jun 2017 20:20:24 +0200 (CEST)

commit f5270aa24148c00b73796b6c7c654c2caaeeb577
Author: Hiltjo Posthuma <hiltjo_AT_codemadness.org>
AuthorDate: Wed Jun 28 18:39:38 2017 +0200
Commit: Laslo Hunhold <dev_AT_frign.de>
CommitDate: Wed Jun 28 20:20:10 2017 +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.

diff --git a/quark.c b/quark.c
index ec58261..9e9c151 100644
--- a/quark.c
+++ b/quark.c
_AT_@ -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
          */
_AT_@ -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++) {
Received on Wed Jun 28 2017 - 20:20:24 CEST

This archive was generated by hypermail 2.3.0 : Wed Jun 28 2017 - 20:24:25 CEST