Skip to content

Commit

Permalink
lib: updatehub: Fix out-of-bounds access
Browse files Browse the repository at this point in the history
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: Gerson Fernando Budke <gerson.budke@ossystems.com.br>
  • Loading branch information
nandojve authored and carlescufi committed Jul 30, 2020
1 parent 3001481 commit 8683b47
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion lib/updatehub/updatehub.c
Original file line number Diff line number Diff line change
Expand Up @@ -216,11 +216,16 @@ static bool start_coap_client(void)

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;
}
Expand Down Expand Up @@ -738,6 +743,8 @@ enum updatehub_response updatehub_probe(void)
goto error;
}

ctx.nfds = 0;

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

0 comments on commit 8683b47

Please sign in to comment.