mgmt: hawkbit: Fix case where body_data not set correctly

When downloading large files from the hawkbit server
 the only time rsp->body_start is checked is on the
first call. After this it is never checked again.

This caused the wrong data to be written to flash
and a failed update.

Signed-off-by: Joep Buruma <burumaj50@gmail.com>
This commit is contained in:
Joep Buruma 2021-05-03 12:21:10 +02:00 committed by Christopher Friedt
commit e45c07cd60

View file

@ -795,8 +795,18 @@ static void response_cb(struct http_response *rsp,
if (hb_context.dl.http_content_size == 0) {
body_data = rsp->body_start;
body_len = rsp->data_len;
/*
* subtract the size of the HTTP header from body_len
*/
body_len -= (rsp->body_start - rsp->recv_buf);
hb_context.dl.http_content_size = rsp->content_length;
} else {
/*
* more general case where body data is set, but no need
* to take the HTTP header into account
*/
body_data = rsp->body_start;
body_len = rsp->data_len;
}
if ((rsp->body_found == 1) && (body_data == NULL)) {