* [PATCH] net-lwip: zero terminate string with headers in wget_lwip_fill_info()
@ 2024-11-25 17:58 Adriano Cordova
0 siblings, 0 replies; only message in thread
From: Adriano Cordova @ 2024-11-25 17:58 UTC (permalink / raw)
To: u-boot
Cc: joe.hershberger, rfried.dev, jerome.forissier, xypron.glpk,
ilias.apalodimas, Adriano Cordova
This patch comes as a companion to the same patch but for the legacy
net stack. Commit 1327c2a8d6 ("net/lwip: wget: integrate struct wget_info
into wget code") introduced function wget_fill_info() which retrieves
the headers from the HTTP server response. As we want to parse the
string in later patches we need to ensure that it is NUL terminated.
We must further check that wget_info->headers in not NULL.
Otherwise a crash occurs.
Fixes: 1327c2a8d6 ("net/lwip: wget: integrate struct wget_info into wget code")
Signed-off-by: Adriano Cordova <adrianox@gmail.com>
---
net/lwip/wget.c | 9 +++++++--
1 file changed, 7 insertions(+), 2 deletions(-)
diff --git a/net/lwip/wget.c b/net/lwip/wget.c
index 53c3b169e0..15cf4e25bd 100644
--- a/net/lwip/wget.c
+++ b/net/lwip/wget.c
@@ -36,8 +36,13 @@ struct wget_ctx {
static void wget_lwip_fill_info(struct pbuf *hdr, u16_t hdr_len, u32_t hdr_cont_len)
{
- if (wget_info->headers && hdr_len < MAX_HTTP_HEADERS_SIZE)
- pbuf_copy_partial(hdr, (void *)wget_info->headers, hdr_len, 0);
+ if (wget_info->headers) {
+ if (wget_info->headers && hdr_len < MAX_HTTP_HEADERS_SIZE)
+ pbuf_copy_partial(hdr, (void *)wget_info->headers, hdr_len, 0);
+ else
+ hdr_len = 0;
+ wget_info->headers[hdr_len] = 0;
+ }
wget_info->hdr_cont_len = (u32)hdr_cont_len;
}
--
2.43.0
^ permalink raw reply related [flat|nested] only message in thread
only message in thread, other threads:[~2024-11-25 17:59 UTC | newest]
Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-11-25 17:58 [PATCH] net-lwip: zero terminate string with headers in wget_lwip_fill_info() Adriano Cordova
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox