mirror of
https://github.com/TalAloni/SMBLibrary.git
synced 2025-07-15 05:45:03 +02:00
FileBasicInformation, SMB_SET_FILE_BASIC_INFO: Bugfix: InvalidDataException was thrown if FILETIME value was set to -1
This commit is contained in:
parent
18a47dfcd5
commit
2b14375876
3 changed files with 28 additions and 9 deletions
|
@ -83,5 +83,25 @@ namespace SMBLibrary
|
||||||
WriteFileTime(buffer, offset, time);
|
WriteFileTime(buffer, offset, time);
|
||||||
offset += 8;
|
offset += 8;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// When setting file attributes, a value of -1 indicates to the server that it MUST NOT change this attribute for all subsequent operations on the same file handle.
|
||||||
|
/// </summary>
|
||||||
|
public static DateTime? ReadSetFileTime(byte[] buffer, int offset)
|
||||||
|
{
|
||||||
|
long span = LittleEndianConverter.ToInt64(buffer, offset);
|
||||||
|
if (span > 0)
|
||||||
|
{
|
||||||
|
return DateTime.FromFileTimeUtc(span);
|
||||||
|
}
|
||||||
|
else if (span == 0 || span == -1)
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
throw new System.IO.InvalidDataException("Set FILETIME cannot be set to a value less than -1");
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -30,10 +30,10 @@ namespace SMBLibrary
|
||||||
|
|
||||||
public FileBasicInformation(byte[] buffer, int offset)
|
public FileBasicInformation(byte[] buffer, int offset)
|
||||||
{
|
{
|
||||||
CreationTime = FileTimeHelper.ReadNullableFileTime(buffer, offset + 0);
|
CreationTime = FileTimeHelper.ReadSetFileTime(buffer, offset + 0);
|
||||||
LastAccessTime = FileTimeHelper.ReadNullableFileTime(buffer, offset + 8);
|
LastAccessTime = FileTimeHelper.ReadSetFileTime(buffer, offset + 8);
|
||||||
LastWriteTime = FileTimeHelper.ReadNullableFileTime(buffer, offset + 16);
|
LastWriteTime = FileTimeHelper.ReadSetFileTime(buffer, offset + 16);
|
||||||
ChangeTime = FileTimeHelper.ReadNullableFileTime(buffer, offset + 24);
|
ChangeTime = FileTimeHelper.ReadSetFileTime(buffer, offset + 24);
|
||||||
FileAttributes = (FileAttributes)LittleEndianConverter.ToUInt32(buffer, offset + 32);
|
FileAttributes = (FileAttributes)LittleEndianConverter.ToUInt32(buffer, offset + 32);
|
||||||
Reserved = LittleEndianConverter.ToUInt32(buffer, offset + 36);
|
Reserved = LittleEndianConverter.ToUInt32(buffer, offset + 36);
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,7 +6,6 @@
|
||||||
*/
|
*/
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Text;
|
|
||||||
using Utilities;
|
using Utilities;
|
||||||
|
|
||||||
namespace SMBLibrary.SMB1
|
namespace SMBLibrary.SMB1
|
||||||
|
@ -35,10 +34,10 @@ namespace SMBLibrary.SMB1
|
||||||
|
|
||||||
public SetFileBasicInfo(byte[] buffer, int offset)
|
public SetFileBasicInfo(byte[] buffer, int offset)
|
||||||
{
|
{
|
||||||
CreationTime = FileTimeHelper.ReadNullableFileTime(buffer, offset + 0);
|
CreationTime = FileTimeHelper.ReadSetFileTime(buffer, offset + 0);
|
||||||
LastAccessTime = FileTimeHelper.ReadNullableFileTime(buffer, offset + 8);
|
LastAccessTime = FileTimeHelper.ReadSetFileTime(buffer, offset + 8);
|
||||||
LastWriteTime = FileTimeHelper.ReadNullableFileTime(buffer, offset + 16);
|
LastWriteTime = FileTimeHelper.ReadSetFileTime(buffer, offset + 16);
|
||||||
LastChangeTime = FileTimeHelper.ReadNullableFileTime(buffer, offset + 24);
|
LastChangeTime = FileTimeHelper.ReadSetFileTime(buffer, offset + 24);
|
||||||
ExtFileAttributes = (ExtendedFileAttributes)LittleEndianConverter.ToUInt32(buffer, offset + 32);
|
ExtFileAttributes = (ExtendedFileAttributes)LittleEndianConverter.ToUInt32(buffer, offset + 32);
|
||||||
Reserved = LittleEndianConverter.ToUInt32(buffer, offset + 36);
|
Reserved = LittleEndianConverter.ToUInt32(buffer, offset + 36);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue