Browse Source

SMBServer: SMB1: Return STATUS_BAD_DEVICE_TYPE when applicable

Tal Aloni 7 years ago
parent
commit
a6f4f166f6
1 changed files with 12 additions and 0 deletions
  1. 12 0
      SMBLibrary/Server/SMB1/TreeConnectHelper.cs

+ 12 - 0
SMBLibrary/Server/SMB1/TreeConnectHelper.cs

@@ -24,6 +24,12 @@ namespace SMBLibrary.Server.SMB1
             OptionalSupportFlags supportFlags;
             if (String.Equals(shareName, NamedPipeShare.NamedPipeShareName, StringComparison.OrdinalIgnoreCase))
             {
+                if (request.Service != ServiceName.AnyType && request.Service != ServiceName.NamedPipe)
+                {
+                    header.Status = NTStatus.STATUS_BAD_DEVICE_TYPE;
+                    return new ErrorResponse(request.CommandName);
+                }
+
                 share = services;
                 serviceName = ServiceName.NamedPipe;
                 supportFlags = OptionalSupportFlags.SMB_SUPPORT_SEARCH_BITS | OptionalSupportFlags.SMB_CSC_NO_CACHING;
@@ -37,6 +43,12 @@ namespace SMBLibrary.Server.SMB1
                     return new ErrorResponse(request.CommandName);
                 }
 
+                if (request.Service != ServiceName.AnyType && request.Service != ServiceName.DiskShare)
+                {
+                    header.Status = NTStatus.STATUS_BAD_DEVICE_TYPE;
+                    return new ErrorResponse(request.CommandName);
+                }
+
                 serviceName = ServiceName.DiskShare;
                 supportFlags = OptionalSupportFlags.SMB_SUPPORT_SEARCH_BITS | GetCachingSupportFlags(((FileSystemShare)share).CachingPolicy);