mirror of
https://source.denx.de/u-boot/u-boot.git
synced 2026-06-02 09:46:37 +03:00
net: zero terminate string with headers in wget_fill_info()
Commit2dd076a9c1("net: wget: integrate struct wget_info into legacy 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:2dd076a9c1("net: wget: integrate struct wget_info into legacy wget code") Signed-off-by: Adriano Cordova <adrianox@gmail.com> Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>
This commit is contained in:
@@ -208,8 +208,13 @@ static void wget_fill_info(const uchar *pkt, int hlen)
|
||||
const char *second_space;
|
||||
char *pos, *end;
|
||||
|
||||
if (wget_info->headers && hlen < MAX_HTTP_HEADERS_SIZE)
|
||||
strncpy(wget_info->headers, pkt, hlen);
|
||||
if (wget_info->headers) {
|
||||
if (hlen < MAX_HTTP_HEADERS_SIZE)
|
||||
strncpy(wget_info->headers, pkt, hlen);
|
||||
else
|
||||
hlen = 0;
|
||||
wget_info->headers[hlen] = 0;
|
||||
}
|
||||
|
||||
//Get status code
|
||||
first_space = strchr(pkt, ' ');
|
||||
|
||||
Reference in New Issue
Block a user