Client: Discard all unsolicited responses except OpLock break

This commit is contained in:
Tal Aloni 2017-12-13 20:24:11 +02:00
parent 5637bb3b9c
commit 7c31666bc3
2 changed files with 20 additions and 6 deletions

View file

@ -456,10 +456,17 @@ namespace SMBLibrary.Client
return;
}
lock (m_incomingQueueLock)
// [MS-CIFS] 3.2.5.1 - If the MID value is the reserved value 0xFFFF, the message can be an OpLock break
// sent by the server. Otherwise, if the PID and MID values of the received message are not found in the
// Client.Connection.PIDMIDList, the message MUST be discarded.
if ((message.Header.MID == 0xFFFF && message.Header.Command == CommandName.SMB_COM_LOCKING_ANDX) ||
(message.Header.PID == 0 && message.Header.MID == 0))
{
m_incomingQueue.Add(message);
m_incomingQueueEventHandle.Set();
lock (m_incomingQueueLock)
{
m_incomingQueue.Add(message);
m_incomingQueueEventHandle.Set();
}
}
}
}

View file

@ -340,10 +340,17 @@ namespace SMBLibrary.Client
return;
}
lock (m_incomingQueueLock)
// [MS-SMB2] 3.2.5.1.2 - If the MessageId is 0xFFFFFFFFFFFFFFFF, this is not a reply to a previous request,
// and the client MUST NOT attempt to locate the request, but instead process it as follows:
// If the command field in the SMB2 header is SMB2 OPLOCK_BREAK, it MUST be processed as specified in 3.2.5.19.
// Otherwise, the response MUST be discarded as invalid.
if (command.Header.MessageID != 0xFFFFFFFFFFFFFFFF || command.Header.Command == SMB2CommandName.OplockBreak)
{
m_incomingQueue.Add(command);
m_incomingQueueEventHandle.Set();
lock (m_incomingQueueLock)
{
m_incomingQueue.Add(command);
m_incomingQueueEventHandle.Set();
}
}
}
}