Skip to content
This repository has been archived by the owner on Sep 19, 2024. It is now read-only.

Commit

Permalink
fix error handling in connect and accept
Browse files Browse the repository at this point in the history
  • Loading branch information
bonifaido committed Apr 17, 2024
1 parent 79543e5 commit 97ebfec
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/socket.c
Original file line number Diff line number Diff line change
Expand Up @@ -2000,9 +2000,7 @@ struct sock *camblet_accept(struct sock *sk, int flags, int *err, bool kern)
opa_socket_context opa_socket_ctx = enriched_socket_eval(conn_ctx, INPUT, client_sk, port);
if (opa_socket_ctx.error < 0)
{
tcp_connection_context_free(conn_ctx);
*err = opa_socket_ctx.error;
opa_socket_context_free(opa_socket_ctx);
goto error;
}

Expand Down Expand Up @@ -2059,6 +2057,8 @@ struct sock *camblet_accept(struct sock *sk, int flags, int *err, bool kern)

error:
camblet_socket_free(sc);
opa_socket_context_free(opa_socket_ctx);
tcp_connection_context_free(conn_ctx);
if (client_sk)
client_sk->sk_prot->close(client_sk, 0);

Expand Down Expand Up @@ -2143,9 +2143,7 @@ int camblet_connect(struct sock *sk, struct sockaddr *uaddr, int addr_len)
opa_socket_context opa_socket_ctx = enriched_socket_eval(conn_ctx, OUTPUT, sk, port);
if (opa_socket_ctx.error < 0)
{
tcp_connection_context_free(conn_ctx);
err = opa_socket_ctx.error;
opa_socket_context_free(opa_socket_ctx);
goto error;
}

Expand Down Expand Up @@ -2209,6 +2207,8 @@ int camblet_connect(struct sock *sk, struct sockaddr *uaddr, int addr_len)

error:
camblet_socket_free(sc);
opa_socket_context_free(opa_socket_ctx);
tcp_connection_context_free(conn_ctx);
socket_reset(sk);

return err;
Expand Down

0 comments on commit 97ebfec

Please sign in to comment.