Fixed InvalidCastException during SMB 2.002 connection

This commit is contained in:
Tal Aloni 2017-01-22 22:24:42 +02:00
parent 3539d3bd31
commit 1679629b47
2 changed files with 10 additions and 2 deletions

View file

@ -47,8 +47,12 @@ namespace SMBLibrary.Server
if (command is NegotiateRequest) if (command is NegotiateRequest)
{ {
NegotiateRequest request = (NegotiateRequest)command; NegotiateRequest request = (NegotiateRequest)command;
state = new SMB2ConnectionState(state, AllocatePersistentFileID); SMB2Command response = NegotiateHelper.GetNegotiateResponse(request, state, m_serverGuid);
return NegotiateHelper.GetNegotiateResponse(request, state, m_serverGuid); if (state.ServerDialect != SMBDialect.NotSet)
{
state = new SMB2ConnectionState(state, AllocatePersistentFileID);
}
return response;
} }
else else
{ {

View file

@ -245,6 +245,10 @@ namespace SMBLibrary.Server
if (smb2Dialects.Count > 0) if (smb2Dialects.Count > 0)
{ {
SMB2Command response = SMB2.NegotiateHelper.GetNegotiateResponse(smb2Dialects, state, m_serverGuid); SMB2Command response = SMB2.NegotiateHelper.GetNegotiateResponse(smb2Dialects, state, m_serverGuid);
if (state.ServerDialect != SMBDialect.NotSet)
{
state = new SMB2ConnectionState(state, AllocatePersistentFileID);
}
TrySendResponse(state, response); TrySendResponse(state, response);
return; return;
} }