Commit 54490e8f authored by Yong Cong Sin's avatar Yong Cong Sin Committed by Christopher Friedt
Browse files

subsys/mgmt/hawkbit: Check retval of mbedtls_md_update



Check the return value of mbedtls_md_update and break on error.

Signed-off-by: default avatarYong Cong Sin <yongcong.sin@gmail.com>
parent 5cee596c
Loading
Loading
Loading
Loading
+8 −2
Original line number Diff line number Diff line
@@ -847,11 +847,17 @@ static void response_cb(struct http_response *rsp,
		}

		if (body_data != NULL) {
			ret = mbedtls_md_update(&hb_context.dl.hash_ctx, body_data,
					  body_len);
			if (ret != 0) {
				LOG_ERR("mbedTLS md update error: %d", ret);
				hb_context.code_status = HAWKBIT_DOWNLOAD_ERROR;
				break;
			}

			ret = flash_img_buffered_write(
				&hb_context.flash_ctx, body_data, body_len,
				final_data == HTTP_DATA_FINAL);
			mbedtls_md_update(&hb_context.dl.hash_ctx, body_data,
					  body_len);
			if (ret < 0) {
				LOG_ERR("Flash write error: %d", ret);
				hb_context.code_status = HAWKBIT_DOWNLOAD_ERROR;