All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] http module is not checking correctly HTTP headers
@ 2022-01-12 22:54 Javier Moragon
  2022-01-13  4:08 ` Glenn Washburn
  0 siblings, 1 reply; 6+ messages in thread
From: Javier Moragon @ 2022-01-12 22:54 UTC (permalink / raw)
  To: grub-devel

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. I've been able to reproduce it and after ignoring the text case
it worked perfectly.

Here is it my patch proposal:

diff --git a/grub-core/net/http.c b/grub-core/net/http.c
index b616cf40b..570fa3934 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: ", grub_strlen
("Content-Length: ") )
       == 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",
+    grub_strlen ("Transfer-Encoding: chunked") ) == 0)
     {
       data->chunked = 1;
       return GRUB_ERR_NONE;


^ permalink raw reply related	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2022-01-14  3:29 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-01-12 22:54 [PATCH] http module is not checking correctly HTTP headers Javier Moragon
2022-01-13  4:08 ` Glenn Washburn
2022-01-13 22:14   ` Javier Moragon
2022-01-13 23:05     ` Jamo
2022-01-14  3:26       ` Glenn Washburn
2022-01-13 23:10     ` Glenn Washburn

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.