mirror of
https://github.com/TalAloni/SMBLibrary.git
synced 2025-04-30 10:47:48 +02:00
SMB2: CreateContext: Bugfix: Read and Write name as ANSI instead of UTF16
This commit is contained in:
parent
019015ebb5
commit
3247f0365e
1 changed files with 5 additions and 5 deletions
|
@ -1,4 +1,4 @@
|
||||||
/* Copyright (C) 2017 Tal Aloni <tal.aloni.il@gmail.com>. All rights reserved.
|
/* Copyright (C) 2017-2024 Tal Aloni <tal.aloni.il@gmail.com>. All rights reserved.
|
||||||
*
|
*
|
||||||
* You can redistribute this program and/or modify it under the terms of
|
* You can redistribute this program and/or modify it under the terms of
|
||||||
* the GNU Lesser Public License as published by the Free Software Foundation,
|
* the GNU Lesser Public License as published by the Free Software Foundation,
|
||||||
|
@ -44,7 +44,7 @@ namespace SMBLibrary.SMB2
|
||||||
DataLength = LittleEndianConverter.ToUInt32(buffer, offset + 12);
|
DataLength = LittleEndianConverter.ToUInt32(buffer, offset + 12);
|
||||||
if (NameLength > 0)
|
if (NameLength > 0)
|
||||||
{
|
{
|
||||||
Name = ByteReader.ReadUTF16String(buffer, offset + NameOffset, NameLength / 2);
|
Name = ByteReader.ReadAnsiString(buffer, offset + NameOffset, NameLength);
|
||||||
}
|
}
|
||||||
if (DataLength > 0)
|
if (DataLength > 0)
|
||||||
{
|
{
|
||||||
|
@ -56,7 +56,7 @@ namespace SMBLibrary.SMB2
|
||||||
{
|
{
|
||||||
LittleEndianWriter.WriteUInt32(buffer, offset + 0, Next);
|
LittleEndianWriter.WriteUInt32(buffer, offset + 0, Next);
|
||||||
NameOffset = 0;
|
NameOffset = 0;
|
||||||
NameLength = (ushort)(Name.Length * 2);
|
NameLength = (ushort)Name.Length;
|
||||||
if (Name.Length > 0)
|
if (Name.Length > 0)
|
||||||
{
|
{
|
||||||
NameOffset = (ushort)FixedLength;
|
NameOffset = (ushort)FixedLength;
|
||||||
|
@ -68,11 +68,11 @@ namespace SMBLibrary.SMB2
|
||||||
DataLength = (uint)Data.Length;
|
DataLength = (uint)Data.Length;
|
||||||
if (Data.Length > 0)
|
if (Data.Length > 0)
|
||||||
{
|
{
|
||||||
int paddedNameLength = (int)Math.Ceiling((double)(Name.Length * 2) / 8) * 8;
|
int paddedNameLength = (int)Math.Ceiling((double)Name.Length / 8) * 8;
|
||||||
DataOffset = (ushort)(FixedLength + paddedNameLength);
|
DataOffset = (ushort)(FixedLength + paddedNameLength);
|
||||||
}
|
}
|
||||||
LittleEndianWriter.WriteUInt16(buffer, offset + 10, DataOffset);
|
LittleEndianWriter.WriteUInt16(buffer, offset + 10, DataOffset);
|
||||||
ByteWriter.WriteUTF16String(buffer, NameOffset, Name);
|
ByteWriter.WriteAnsiString(buffer, NameOffset, Name);
|
||||||
ByteWriter.WriteBytes(buffer, DataOffset, Data);
|
ByteWriter.WriteBytes(buffer, DataOffset, Data);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue