On 11/1/26 06:53, Igor Velkov via B4 Relay wrote:
From: Igor Velkov <[email protected]>
lwIP passes 0xffffffff as the content length when a reply has no usable
Content-Length header. With check_buffer_size set, wget compares that
value with the buffer size and refuses the download whenever the
buffer is smaller than 4 GiB, before any data arrives.
Skip the check when the length is unknown, as the legacy wget does.
store_block() still stops a download that outgrows the buffer.
Fixes: 1327c2a8d651 ("net/lwip: wget: integrate struct wget_info into wget
code")
Signed-off-by: Igor Velkov <[email protected]>
---
net/lwip/wget.c | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/net/lwip/wget.c b/net/lwip/wget.c
index 96ee600c5e1..615ea035a28 100644
--- a/net/lwip/wget.c
+++ b/net/lwip/wget.c
@@ -6,6 +6,7 @@
#include <display_options.h>
#include <efi_loader.h>
#include <env.h>
+#include <limits.h>
#include <linux/kconfig.h>
#include <lwip/apps/http_client.h>
#include "lwip/altcp_tls.h"
@@ -285,7 +286,9 @@ static err_t httpc_headers_done_cb(httpc_state_t
*connection, void *arg, struct
wget_lwip_fill_info(hdr, hdr_len, content_len);
- if (wget_info->check_buffer_size && (ulong)content_len > wget_info->buffer_size)
+ /* lwIP passes U32_MAX when the reply has no usable Content-Length */
+ if (wget_info->check_buffer_size && content_len != U32_MAX &&
Hello Igor,
A constant of this name does not exist in LWIP. Do you mean
HTTPC_CONTENT_LEN_INVALID ?
Using this constant would make the code better readable and not require
a comment.
A script like the following probably could be used for testing:
python3 -c '
import functools, http.server
class Handler(http.server.SimpleHTTPRequestHandler):
def send_header(self, keyword, value):
if keyword.lower() != "content-length":
super().send_header(keyword, value)
http.server.test(
HandlerClass=functools.partial(Handler, directory="/path/to/dir"),
port=8080,
)
'
I am not sure if would want to add this to our CI for just testing a
corner case.
Best regards
Heinrich
+ (ulong)content_len > wget_info->buffer_size)
return ERR_BUF;
ctx->content_len = content_len;