Workaround to prevent Windows 7 / 8 / 10 from sending ChangeNotify requests infinitely

This commit is contained in:
Tal Aloni 2017-02-26 20:54:36 +02:00
parent c8b66a16c9
commit 64702908d9

View file

@ -135,6 +135,20 @@ namespace SMBLibrary.Server
}
else
{
// Cancel requests can have an ASYNC header (TreeID will not be present)
if (command is CancelRequest)
{
if (command.Header.IsAsync && command.Header.AsyncID == 0)
{
ErrorResponse response = new ErrorResponse(command.CommandName, NTStatus.STATUS_CANCELLED);
response.Header.IsAsync = true;
return response;
}
// [MS-SMB2] If a request is not found, the server MUST stop processing for this cancel request. No response is sent.
return null;
}
ISMBShare share = session.GetConnectedTree(command.Header.TreeID);
if (share == null)
{
@ -196,7 +210,11 @@ namespace SMBLibrary.Server
else if (command is ChangeNotifyRequest)
{
// [MS-SMB2] If the underlying object store does not support change notifications, the server MUST fail this request with STATUS_NOT_SUPPORTED
return new ErrorResponse(command.CommandName, NTStatus.STATUS_NOT_SUPPORTED);
ErrorResponse response = new ErrorResponse(command.CommandName, NTStatus.STATUS_NOT_SUPPORTED);
// Windows 7 / 8 / 10 will infinitely retry sending ChangeNotify requests if the response does not have SMB2_FLAGS_ASYNC_COMMAND set.
// Note: NoRemoteChangeNotify can be set in the registry to prevent the client from sending ChangeNotify requests altogether.
response.Header.IsAsync = true;
return response;
}
}
}