FileRenameInformationType2: Bugfix: Ensure length is at least 24 bytes

This commit is contained in:
Tal Aloni 2024-01-17 22:34:44 +02:00
parent c284b05782
commit 39388660d3

View file

@ -1,18 +1,16 @@
/* Copyright (C) 2014-2017 Tal Aloni <tal.aloni.il@gmail.com>. All rights reserved. /* Copyright (C) 2014-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,
* either version 3 of the License, or (at your option) any later version. * either version 3 of the License, or (at your option) any later version.
*/ */
using System; using System;
using System.Collections.Generic;
using System.Text;
using Utilities; using Utilities;
namespace SMBLibrary namespace SMBLibrary
{ {
/// <summary> /// <summary>
/// [MS-FSCC] 2.4.34.2 - FileRenameInformation Type 2 /// [MS-FSCC] 2.4.37.2 - FileRenameInformation Type 2
/// </summary> /// </summary>
/// <remarks> /// <remarks>
/// [MS-FSA] 2.1.5.14.11 /// [MS-FSA] 2.1.5.14.11
@ -28,6 +26,7 @@ namespace SMBLibrary
public ulong RootDirectory; public ulong RootDirectory;
private uint FileNameLength; private uint FileNameLength;
public string FileName = String.Empty; public string FileName = String.Empty;
// Padding - the number of bytes required to make the size of this structure at least 24.
public FileRenameInformationType2() public FileRenameInformationType2()
{ {
@ -62,7 +61,7 @@ namespace SMBLibrary
{ {
get get
{ {
return FixedLength + FileName.Length * 2; return Math.Max(FixedLength + FileName.Length * 2, 24);
} }
} }
} }