From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from list by lists.gnu.org with archive (Exim 4.90_1) id 1n8U1A-00017q-Pp for mharc-grub-devel@gnu.org; Fri, 14 Jan 2022 16:21:52 -0500 Received: from eggs.gnu.org ([209.51.188.92]:55918) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1n8U19-00017B-Dn for grub-devel@gnu.org; Fri, 14 Jan 2022 16:21:51 -0500 Received: from [2a00:1450:4864:20::32c] (port=40565 helo=mail-wm1-x32c.google.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1n8U10-0002wv-Jo for grub-devel@gnu.org; Fri, 14 Jan 2022 16:21:44 -0500 Received: by mail-wm1-x32c.google.com with SMTP id 25-20020a05600c231900b003497473a9c4so9443517wmo.5 for ; Fri, 14 Jan 2022 13:21:41 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=EikwVtEQ9khPt9BPz9PjsrdHZ17olJpWAq4wyS5kTxQ=; b=HAB7Wj+uswDe3g8EXnmtonGYyNgbaxMJewUCUQmtzDjDCd8l+pfLPfiNUNE3gCi9hG bZBwut8Qw75jCl+jW3jSrY/VzLJw/WmKVEtWVSmVkXA8C8sj8mNlxyWWyuzSJT4YjGxh nuWVUlvGW0CY6FX2wxFBzlwySJAkKgvfIYLQhsvJvx1ZcuoE1KtLy/i8jnJ1HCrtRkry eJy721C0sBgglKD9gfaq5z1wh13xipR7ShW//pxPbuxXJsPQcVwriusuIFdvY1JfIJc/ YH2fWMSj6CrHqaYLCEzmD+qhhzII23+Uiwbx5XVhT14junLTkJtTuhvUf/c3OD6bkkaA toAg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=EikwVtEQ9khPt9BPz9PjsrdHZ17olJpWAq4wyS5kTxQ=; b=FjpKyHJCti2Gq7kXiQpIY4IEP05Iu6hN8T51/IVZM6zq9PAnuoMFVxWhF0ksWLG+QG NaE5WhoFMl8bwGLgCP+cQ2OzAvHs50TuTx8qp8PmQBMMag+LkAAR5DEpzCRPkqF2/h+Z CIb8bhmhjqhBustwTXt6qBxBMRSZWFkzmyy/7h3oWt2NItGm0c8qIE3HEL4kObflwc0V o2EOPp05kI9OS8Mo1M9MpW9t5ewjt5qcDUucSYchkWLPHFJNQtXSXpTdfQUQN0M66Oqr 774h3UqKtqpVJ7LKxc1O3Kh708+7NDI7/13dyWJ28/HqI7WFKeuwuV1sO9KOV/1Hfrev P0AQ== X-Gm-Message-State: AOAM533jrfb502rezIsbN++ZuxMWAiuOmGQIcdBzxMDKn1rYudVV52t5 6gJHsABpj9QikwByM4ec+2NagwvvIg9ySPyU X-Google-Smtp-Source: ABdhPJwJkyRJz3yXPGJWb7Wd9do8R7XyQRdvjvYGcOelejwc8gM+VKf83nB6MAkp1GguAfg1ZYdxgQ== X-Received: by 2002:a5d:584e:: with SMTP id i14mr9829227wrf.255.1642195298975; Fri, 14 Jan 2022 13:21:38 -0800 (PST) Received: from localhost.localdomain (17.red-81-39-144.dynamicip.rima-tde.net. [81.39.144.17]) by smtp.gmail.com with ESMTPSA id bh26sm11949240wmb.3.2022.01.14.13.21.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 14 Jan 2022 13:21:38 -0800 (PST) From: Jamo To: grub-devel@gnu.org Cc: Jamo Subject: [PATCH] http: parse HTTP headers case-insensitive Date: Fri, 14 Jan 2022 22:20:17 +0100 Message-Id: <20220114212016.6420-1-jamofer@gmail.com> X-Mailer: git-send-email 2.32.0 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Host-Lookup-Failed: Reverse DNS lookup failed for 2a00:1450:4864:20::32c (failed) Received-SPF: pass client-ip=2a00:1450:4864:20::32c; envelope-from=jamofer@gmail.com; helo=mail-wm1-x32c.google.com X-Spam_score_int: -12 X-Spam_score: -1.3 X-Spam_bar: - X-Spam_report: (-1.3 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, PDS_HP_HELO_NORDNS=0.001, RCVD_IN_DNSWL_NONE=-0.0001, RDNS_NONE=0.793, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: grub-devel@gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: The development of GNU GRUB List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 14 Jan 2022 21:21:51 -0000 According to https://www.ietf.org/rfc/rfc2616.txt 4.2, header names shall be case insensitive and we are now forced to read headers like `Content-Length` capitalized. The problem with that is when a HTTP server responds with a `content-length` header in lowercase GRUB gets stuck because HTTP module doesn't know the length of the transmision and the call never ends. --- grub-core/net/http.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/grub-core/net/http.c b/grub-core/net/http.c index b616cf40b..d3ba8c799 100644 --- a/grub-core/net/http.c +++ b/grub-core/net/http.c @@ -130,7 +130,7 @@ parse_line (grub_file_t file, http_data_t data, char *ptr, grub_size_t len) data->first_line_recv = 1; return GRUB_ERR_NONE; } - if (grub_memcmp (ptr, "Content-Length: ", sizeof ("Content-Length: ") - 1) + if (grub_strncasecmp (ptr, "Content-Length: ", sizeof ("Content-Length: ") - 1) == 0 && !data->size_recv) { ptr += sizeof ("Content-Length: ") - 1; @@ -138,8 +138,8 @@ parse_line (grub_file_t file, http_data_t data, char *ptr, grub_size_t len) data->size_recv = 1; return GRUB_ERR_NONE; } - if (grub_memcmp (ptr, "Transfer-Encoding: chunked", - sizeof ("Transfer-Encoding: chunked") - 1) == 0) + if (grub_strncasecmp (ptr, "Transfer-Encoding: chunked", + sizeof ("Transfer-Encoding: chunked") - 1) == 0) { data->chunked = 1; return GRUB_ERR_NONE; -- 2.32.0