Commit c2e60a4e authored by Gerson Fernando Budke's avatar Gerson Fernando Budke Committed by Anas Nashif
Browse files

lib: updatehub: Fix out-of-bounds access



The struct pollfd context variable is not proper initialized and index
is out-of-bounds. Adjusts index to be inside scope boundary.

Fixes #26993.

Signed-off-by: default avatarGerson Fernando Budke <gerson.budke@ossystems.com.br>
parent 44fc9dca
Loading
Loading
Loading
Loading
+8 −1
Original line number Diff line number Diff line
@@ -148,11 +148,16 @@ is_compatible_hardware(struct resp_probe_some_boards *metadata_some_boards)

static void cleanup_connection(void)
{
	int i;

	if (close(ctx.sock) < 0) {
		LOG_ERR("Could not close the socket");
	}

	memset(&ctx.fds[1], 0, sizeof(ctx.fds[1]));
	for (i = 0; i < ctx.nfds; i++) {
		memset(&ctx.fds[i], 0, sizeof(ctx.fds[i]));
	}

	ctx.nfds = 0;
	ctx.sock = 0;
}
@@ -750,6 +755,8 @@ enum updatehub_response updatehub_probe(void)
		goto error;
	}

	ctx.nfds = 0;

	if (!start_coap_client()) {
		ctx.code_status = UPDATEHUB_NETWORKING_ERROR;
		goto error;