Skip to content

Commit

Permalink
net/mbedtls_net_connect: Preventing double close problem
Browse files Browse the repository at this point in the history
In the test examples and real usage scenarios, 'mbedtls_net_free' is called after 'mbedtls_net_connect' fails, which will cause the problem of double close the same fd. It is possible to close this closed fd which has been applied by other link.

Signed-off-by: makejian <[email protected]>
  • Loading branch information
ThePassionate committed Oct 22, 2024
1 parent 17d2fb8 commit d8cae48
Showing 1 changed file with 1 addition and 0 deletions.
1 change: 1 addition & 0 deletions library/net_sockets.c
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,7 @@ int mbedtls_net_connect(mbedtls_net_context *ctx, const char *host,
}

close(ctx->fd);
ctx->fd = -1;
ret = MBEDTLS_ERR_NET_CONNECT_FAILED;
}

Expand Down

0 comments on commit d8cae48

Please sign in to comment.