diff options
author | Andrew Tridgell <tridge@samba.org> | 2005-07-13 03:25:36 +0000 |
---|---|---|
committer | Gerald (Jerry) Carter <jerry@samba.org> | 2007-10-10 13:22:59 -0500 |
commit | d1291dacbd8c5e736e7d8288fb00b5368288b711 (patch) | |
tree | d0f01432dd6f2728f00fc3419797a71be7afe71c /source4/lib | |
parent | 562498c5260108c17add1e1a392644d188ff5c79 (diff) | |
download | samba-d1291dacbd8c5e736e7d8288fb00b5368288b711.tar.gz samba-d1291dacbd8c5e736e7d8288fb00b5368288b711.tar.bz2 samba-d1291dacbd8c5e736e7d8288fb00b5368288b711.zip |
r8408: its quite common in our code to free up a connection when we get an
error, but sometimes a socket option may then happen on the NULL
socket. This has been handled by the individual libraries up to now,
but its cleaner to centralise it here
(This used to be commit d9864e1f9aac1fb19f054c2da996a5099e90941e)
Diffstat (limited to 'source4/lib')
-rw-r--r-- | source4/lib/socket/socket.c | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/source4/lib/socket/socket.c b/source4/lib/socket/socket.c index 9d5b67a966..db249522a2 100644 --- a/source4/lib/socket/socket.c +++ b/source4/lib/socket/socket.c @@ -98,6 +98,9 @@ NTSTATUS socket_connect(struct socket_context *sock, const char *server_address, int server_port, uint32_t flags) { + if (sock == NULL) { + return NT_STATUS_CONNECTION_DISCONNECTED; + } if (sock->state != SOCKET_STATE_UNDEFINED) { return NT_STATUS_INVALID_PARAMETER; } @@ -119,6 +122,9 @@ NTSTATUS socket_connect_complete(struct socket_context *sock, uint32_t flags) NTSTATUS socket_listen(struct socket_context *sock, const char *my_address, int port, int queue_size, uint32_t flags) { + if (sock == NULL) { + return NT_STATUS_CONNECTION_DISCONNECTED; + } if (sock->state != SOCKET_STATE_UNDEFINED) { return NT_STATUS_INVALID_PARAMETER; } @@ -134,6 +140,9 @@ NTSTATUS socket_accept(struct socket_context *sock, struct socket_context **new_ { NTSTATUS status; + if (sock == NULL) { + return NT_STATUS_CONNECTION_DISCONNECTED; + } if (sock->type != SOCKET_TYPE_STREAM) { return NT_STATUS_INVALID_PARAMETER; } @@ -158,6 +167,9 @@ NTSTATUS socket_accept(struct socket_context *sock, struct socket_context **new_ NTSTATUS socket_recv(struct socket_context *sock, void *buf, size_t wantlen, size_t *nread, uint32_t flags) { + if (sock == NULL) { + return NT_STATUS_CONNECTION_DISCONNECTED; + } if (sock->state != SOCKET_STATE_CLIENT_CONNECTED && sock->state != SOCKET_STATE_SERVER_CONNECTED && sock->type != SOCKET_TYPE_DGRAM) { @@ -183,6 +195,9 @@ NTSTATUS socket_recvfrom(struct socket_context *sock, void *buf, size_t wantlen, size_t *nread, uint32_t flags, const char **src_addr, int *src_port) { + if (sock == NULL) { + return NT_STATUS_CONNECTION_DISCONNECTED; + } if (sock->type != SOCKET_TYPE_DGRAM) { return NT_STATUS_INVALID_PARAMETER; } @@ -198,6 +213,9 @@ NTSTATUS socket_recvfrom(struct socket_context *sock, void *buf, NTSTATUS socket_send(struct socket_context *sock, const DATA_BLOB *blob, size_t *sendlen, uint32_t flags) { + if (sock == NULL) { + return NT_STATUS_CONNECTION_DISCONNECTED; + } if (sock->state != SOCKET_STATE_CLIENT_CONNECTED && sock->state != SOCKET_STATE_SERVER_CONNECTED) { return NT_STATUS_INVALID_PARAMETER; @@ -225,6 +243,9 @@ NTSTATUS socket_sendto(struct socket_context *sock, const DATA_BLOB *blob, size_t *sendlen, uint32_t flags, const char *dest_addr, int dest_port) { + if (sock == NULL) { + return NT_STATUS_CONNECTION_DISCONNECTED; + } if (sock->type != SOCKET_TYPE_DGRAM) { return NT_STATUS_INVALID_PARAMETER; } @@ -247,6 +268,9 @@ NTSTATUS socket_sendto(struct socket_context *sock, */ NTSTATUS socket_pending(struct socket_context *sock, size_t *npending) { + if (sock == NULL) { + return NT_STATUS_CONNECTION_DISCONNECTED; + } if (!sock->ops->fn_pending) { return NT_STATUS_NOT_IMPLEMENTED; } @@ -256,6 +280,9 @@ NTSTATUS socket_pending(struct socket_context *sock, size_t *npending) NTSTATUS socket_set_option(struct socket_context *sock, const char *option, const char *val) { + if (sock == NULL) { + return NT_STATUS_CONNECTION_DISCONNECTED; + } if (!sock->ops->fn_set_option) { return NT_STATUS_NOT_IMPLEMENTED; } |