mirror of
https://github.com/TalAloni/SMBLibrary.git
synced 2025-07-14 05:15:03 +02:00
NTDirectoryFileSystem: QueryDirectory / GetFileSystemInformation: Prevent possibility of reading data beyond the number of bytes written
This commit is contained in:
parent
d00d097b34
commit
fbb229d2c5
1 changed files with 5 additions and 1 deletions
|
@ -264,9 +264,11 @@ namespace SMBLibrary.Win32
|
||||||
{
|
{
|
||||||
return status;
|
return status;
|
||||||
}
|
}
|
||||||
restartScan = false;
|
int numberOfBytesWritten = (int)ioStatusBlock.Information;
|
||||||
|
buffer = ByteReader.ReadBytes(buffer, 0, numberOfBytesWritten);
|
||||||
List<QueryDirectoryFileInformation> page = QueryDirectoryFileInformation.ReadFileInformationList(buffer, 0, informationClass);
|
List<QueryDirectoryFileInformation> page = QueryDirectoryFileInformation.ReadFileInformationList(buffer, 0, informationClass);
|
||||||
result.AddRange(page);
|
result.AddRange(page);
|
||||||
|
restartScan = false;
|
||||||
}
|
}
|
||||||
fileNameStructure.Dispose();
|
fileNameStructure.Dispose();
|
||||||
return NTStatus.STATUS_SUCCESS;
|
return NTStatus.STATUS_SUCCESS;
|
||||||
|
@ -353,6 +355,8 @@ namespace SMBLibrary.Win32
|
||||||
CloseFile(volumeHandle);
|
CloseFile(volumeHandle);
|
||||||
if (status == NTStatus.STATUS_SUCCESS)
|
if (status == NTStatus.STATUS_SUCCESS)
|
||||||
{
|
{
|
||||||
|
int numberOfBytesWritten = (int)ioStatusBlock.Information;
|
||||||
|
buffer = ByteReader.ReadBytes(buffer, 0, numberOfBytesWritten);
|
||||||
result = FileSystemInformation.GetFileSystemInformation(buffer, 0, informationClass);
|
result = FileSystemInformation.GetFileSystemInformation(buffer, 0, informationClass);
|
||||||
}
|
}
|
||||||
return status;
|
return status;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue