diff --git a/SMBLibrary/Client/SMB1FileStore.cs b/SMBLibrary/Client/SMB1FileStore.cs index 6ac04ab..e7b8b88 100644 --- a/SMBLibrary/Client/SMB1FileStore.cs +++ b/SMBLibrary/Client/SMB1FileStore.cs @@ -1,4 +1,4 @@ -/* Copyright (C) 2014-2023 Tal Aloni . All rights reserved. +/* Copyright (C) 2014-2024 Tal Aloni . All rights reserved. * * You can redistribute this program and/or modify it under the terms of * the GNU Lesser Public License as published by the Free Software Foundation, @@ -181,7 +181,11 @@ namespace SMBLibrary.Client TrySendMessage(request); reply = m_client.WaitForMessage(CommandName.SMB_COM_TRANSACTION2); - if (reply.Header.Status == NTStatus.STATUS_SUCCESS && reply.Commands[0] is Transaction2Response) + if (reply == null) + { + return NTStatus.STATUS_INVALID_SMB; + } + else if (reply.Header.Status == NTStatus.STATUS_SUCCESS && reply.Commands[0] is Transaction2Response) { response = (Transaction2Response)reply.Commands[0]; Transaction2FindNext2Response nextSubcommandResponse = new Transaction2FindNext2Response(response.TransParameters, response.TransData, reply.Header.UnicodeFlag); diff --git a/SMBLibrary/Client/SMB2FileStore.cs b/SMBLibrary/Client/SMB2FileStore.cs index 563514c..81aeec1 100644 --- a/SMBLibrary/Client/SMB2FileStore.cs +++ b/SMBLibrary/Client/SMB2FileStore.cs @@ -1,4 +1,4 @@ -/* Copyright (C) 2017-2023 Tal Aloni . All rights reserved. +/* Copyright (C) 2017-2024 Tal Aloni . All rights reserved. * * You can redistribute this program and/or modify it under the terms of * the GNU Lesser Public License as published by the Free Software Foundation, @@ -165,6 +165,10 @@ namespace SMBLibrary.Client request.Reopen = false; TrySendCommand(request); response = m_client.WaitForCommand(request.MessageID); + if (response == null) + { + return NTStatus.STATUS_INVALID_SMB; + } } return response.Header.Status; }