Commit e45c07cd authored by Joep Buruma's avatar Joep Buruma Committed by Christopher Friedt
Browse files

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: default avatarJoep Buruma <burumaj50@gmail.com>
parent 6cb1e22f
Loading
Loading
Loading
Loading
+10 −0
Original line number Diff line number Diff line
@@ -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)) {