From d7b01752491b0cd4389d1f29f1a17c1ab4394357 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Mon, 23 Apr 2007 10:39:20 +0000 Subject: r22485: don't crash when the main dcerpc code haven't setup transport.recv_data yet also return always a usefull error metze (This used to be commit 0a8b4c328dfac972186564d2a4e1757d5135ec47) --- source4/librpc/rpc/dcerpc_smb.c | 12 +++++++++++- source4/librpc/rpc/dcerpc_smb2.c | 12 +++++++++++- source4/librpc/rpc/dcerpc_sock.c | 2 +- 3 files changed, 23 insertions(+), 3 deletions(-) diff --git a/source4/librpc/rpc/dcerpc_smb.c b/source4/librpc/rpc/dcerpc_smb.c index 55fc37d84f..5100eb60f2 100644 --- a/source4/librpc/rpc/dcerpc_smb.c +++ b/source4/librpc/rpc/dcerpc_smb.c @@ -39,7 +39,17 @@ struct smb_private { */ static void pipe_dead(struct dcerpc_connection *c, NTSTATUS status) { - c->transport.recv_data(c, NULL, status); + if (NT_STATUS_EQUAL(NT_STATUS_UNSUCCESSFUL, status)) { + status = NT_STATUS_UNEXPECTED_NETWORK_ERROR; + } + + if (NT_STATUS_EQUAL(NT_STATUS_OK, status)) { + status = NT_STATUS_END_OF_FILE; + } + + if (c->transport.recv_data) { + c->transport.recv_data(c, NULL, status); + } } diff --git a/source4/librpc/rpc/dcerpc_smb2.c b/source4/librpc/rpc/dcerpc_smb2.c index d2ab47898e..385cb00919 100644 --- a/source4/librpc/rpc/dcerpc_smb2.c +++ b/source4/librpc/rpc/dcerpc_smb2.c @@ -41,7 +41,17 @@ struct smb2_private { */ static void pipe_dead(struct dcerpc_connection *c, NTSTATUS status) { - c->transport.recv_data(c, NULL, status); + if (NT_STATUS_EQUAL(NT_STATUS_UNSUCCESSFUL, status)) { + status = NT_STATUS_UNEXPECTED_NETWORK_ERROR; + } + + if (NT_STATUS_EQUAL(NT_STATUS_OK, status)) { + status = NT_STATUS_END_OF_FILE; + } + + if (c->transport.recv_data) { + c->transport.recv_data(c, NULL, status); + } } diff --git a/source4/librpc/rpc/dcerpc_sock.c b/source4/librpc/rpc/dcerpc_sock.c index fd54a20afc..e1ba2d769d 100644 --- a/source4/librpc/rpc/dcerpc_sock.c +++ b/source4/librpc/rpc/dcerpc_sock.c @@ -76,7 +76,7 @@ static void sock_dead(struct dcerpc_connection *p, NTSTATUS status) status = NT_STATUS_END_OF_FILE; } - if (!NT_STATUS_IS_OK(status)) { + if (p->transport.recv_data) { p->transport.recv_data(p, NULL, status); } } -- cgit