summaryrefslogtreecommitdiff
path: root/source4
diff options
context:
space:
mode:
authorAndrew Tridgell <tridge@samba.org>2005-08-01 19:48:16 +0000
committerGerald (Jerry) Carter <jerry@samba.org>2007-10-10 13:30:15 -0500
commit1f467c50d945a24d2885e5bb894676a26f94b86e (patch)
tree332a70457259dbcad02865e292b559700138a5b9 /source4
parentfc585709402e6840a5dd16c9a3fb22792ddacf3e (diff)
downloadsamba-1f467c50d945a24d2885e5bb894676a26f94b86e.tar.gz
samba-1f467c50d945a24d2885e5bb894676a26f94b86e.tar.bz2
samba-1f467c50d945a24d2885e5bb894676a26f94b86e.zip
r8893: fixed the valgrind error on stream termination due to prototol errors
(This used to be commit cf1a7bbe96e8e40ac4df3eaa3e5922a944b45579)
Diffstat (limited to 'source4')
-rw-r--r--source4/smb_server/smb_server.c13
-rw-r--r--source4/smb_server/smb_server.h3
2 files changed, 12 insertions, 4 deletions
diff --git a/source4/smb_server/smb_server.c b/source4/smb_server/smb_server.c
index b632bfefd2..d1fdd2b116 100644
--- a/source4/smb_server/smb_server.c
+++ b/source4/smb_server/smb_server.c
@@ -659,7 +659,7 @@ error:
*/
void smbsrv_terminate_connection(struct smbsrv_connection *smb_conn, const char *reason)
{
- stream_terminate_connection(smb_conn->connection, reason);
+ smb_conn->terminate = True;
}
/*
@@ -684,10 +684,10 @@ static void smbsrv_recv(struct stream_connection *conn, uint16_t flags)
smb_conn->processing = True;
status = receive_smb_request(smb_conn);
smb_conn->processing = False;
- if (NT_STATUS_IS_ERR(status)) {
+ if (NT_STATUS_IS_ERR(status) || smb_conn->terminate) {
talloc_free(conn->event.fde);
conn->event.fde = NULL;
- smbsrv_terminate_connection(smb_conn, nt_errstr(status));
+ stream_terminate_connection(smb_conn->connection, nt_errstr(status));
return;
}
@@ -717,7 +717,7 @@ static void smbsrv_send(struct stream_connection *conn, uint16_t flags)
status = socket_send(conn->socket, &blob, &sendlen, 0);
if (NT_STATUS_IS_ERR(status)) {
smbsrv_terminate_connection(req->smb_conn, nt_errstr(status));
- return;
+ break;
}
if (sendlen == 0) {
break;
@@ -733,6 +733,11 @@ static void smbsrv_send(struct stream_connection *conn, uint16_t flags)
}
}
+ if (smb_conn->terminate) {
+ stream_terminate_connection(smb_conn->connection, "send termination");
+ return;
+ }
+
/* if no more requests are pending to be sent then
we should stop select for write */
if (smb_conn->pending_send == NULL) {
diff --git a/source4/smb_server/smb_server.h b/source4/smb_server/smb_server.h
index 46e480e77c..13dc056f86 100644
--- a/source4/smb_server/smb_server.h
+++ b/source4/smb_server/smb_server.h
@@ -265,6 +265,9 @@ struct smbsrv_connection {
BOOL processing;
+ /* mark a connection for termination */
+ BOOL terminate;
+
/* configuration parameters */
struct {
enum security_types security;