It appears that when using SMB to macOS, there was a case when the smb2client gave STATUS_BUFFER_OVERFLOW on ListShares. Then it will abort as error. According to MS docu https://learn.microsoft.com/en-us/windows-hardware/drivers/kernel/using-ntstatus-values, it should only be a warning and it might still return relevant data. Sadly, I only saw the issue in a log file, so I cannot replicate it right now, but still wanted to report it in.
SMBLibrary: 1.5.0
Used from: Android 14
I played a bit around with AI on this topic to try to use at least the first batch of data, if there is any. It does not request more data as it probably should in a clean implementation. Feel free to ignore it if it doesn't make sense:
- In SMBLibrary Client helper (ServerServiceHelper.ListShares), the code treated non-STATUS_SUCCESS as immediate failure after named pipe RPC calls.
- For SMB2, DeviceIOControl on FSCTL_PIPE_TRANSCEIVE can return STATUS_BUFFER_OVERFLOW and still provide output bytes.
- Because ListShares rejected that status early, share enumeration data could be discarded before parsing.
Code Change Implemented
File changed:
- SMBLibrary/Client/Helpers/ServerServiceHelper.cs
What changed:
- Replaced strict checks:
- from: status == STATUS_SUCCESS only
- to: allow STATUS_SUCCESS or STATUS_BUFFER_OVERFLOW when output payload exists
- Added helper method:
- IsUsableRpcPipePayloadStatus(NTStatus status, byte[] output)
- returns true only when output is non-null/non-empty and status is SUCCESS or BUFFER_OVERFLOW
- Applied to:
- initial DeviceIOControl(FSCTL_PIPE_TRANSCEIVE) response handling
- continuation ReadFile response handling in fragment loop
Scope intentionally limited:
- No pagination/resume-handle work added yet
- No broad result-code remapping added yet
- No cleanup refactor (pipe handle leak paths) in this pass
Suggested Next Steps (Future)
Implement proper NetrShareEnum continuation support:
- Handle RPC result ERROR_MORE_DATA
- Send follow-up requests with resume handle until completion or limit
- Merge all returned entries robustly
Improve RPC/SRVSVC result mapping:
- Add explicit handling for more Win32 results (including ERROR_MORE_DATA)
- Preserve partial results where meaningful
Fix resource cleanup paths:
- Ensure pipe handle close in finally block to avoid leak on early returns
Patch (no pagination):
listshares-buffer-overflow-fix.patch
Many thanks for looking at it and your great library!
It appears that when using SMB to macOS, there was a case when the smb2client gave STATUS_BUFFER_OVERFLOW on ListShares. Then it will abort as error. According to MS docu https://learn.microsoft.com/en-us/windows-hardware/drivers/kernel/using-ntstatus-values, it should only be a warning and it might still return relevant data. Sadly, I only saw the issue in a log file, so I cannot replicate it right now, but still wanted to report it in.
SMBLibrary: 1.5.0
Used from: Android 14
I played a bit around with AI on this topic to try to use at least the first batch of data, if there is any. It does not request more data as it probably should in a clean implementation. Feel free to ignore it if it doesn't make sense:
Code Change Implemented
File changed:
What changed:
Scope intentionally limited:
Suggested Next Steps (Future)
Implement proper NetrShareEnum continuation support:
Improve RPC/SRVSVC result mapping:
Fix resource cleanup paths:
Patch (no pagination):
listshares-buffer-overflow-fix.patch
Many thanks for looking at it and your great library!