From 6a03cfd95288c37740964681e8e204a075ad4dca Mon Sep 17 00:00:00 2001 From: Tal Aloni Date: Sat, 23 Sep 2017 13:30:26 +0300 Subject: [PATCH] Client: Throw Exception if attemping to logoff when the client is not connected --- SMBLibrary/Client/SMB1Client.cs | 5 +++++ SMBLibrary/Client/SMB2Client.cs | 5 +++++ 2 files changed, 10 insertions(+) diff --git a/SMBLibrary/Client/SMB1Client.cs b/SMBLibrary/Client/SMB1Client.cs index 01b34c5..12ceffd 100644 --- a/SMBLibrary/Client/SMB1Client.cs +++ b/SMBLibrary/Client/SMB1Client.cs @@ -236,6 +236,11 @@ namespace SMBLibrary.Client public NTStatus Logoff() { + if (!m_isConnected) + { + throw new InvalidOperationException("A login session must be successfully established before attempting logoff"); + } + LogoffAndXRequest request = new LogoffAndXRequest(); TrySendMessage(request); diff --git a/SMBLibrary/Client/SMB2Client.cs b/SMBLibrary/Client/SMB2Client.cs index 0031408..9fc83df 100644 --- a/SMBLibrary/Client/SMB2Client.cs +++ b/SMBLibrary/Client/SMB2Client.cs @@ -162,6 +162,11 @@ namespace SMBLibrary.Client public NTStatus Logoff() { + if (!m_isConnected) + { + throw new InvalidOperationException("A login session must be successfully established before attempting logoff"); + } + LogoffRequest request = new LogoffRequest(); TrySendCommand(request);