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: Gerson Fernando Budke <gerson.budke@ossystems.com.br>
This commit is contained in:
parent
300148121a
commit
8683b47b17
1 changed files with 8 additions and 1 deletions
|
@ -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;
|
||||
}
|
||||
|
@ -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;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue