Skip to content

Commit

Permalink
Fix variant decoding when rank is present.
Browse files Browse the repository at this point in the history
  • Loading branch information
nauful committed Dec 7, 2023
1 parent 97b6f95 commit cef29f8
Show file tree
Hide file tree
Showing 5 changed files with 4 additions and 16 deletions.
9 changes: 2 additions & 7 deletions NET Core/LibUA/Encoding.cs
Original file line number Diff line number Diff line change
Expand Up @@ -889,13 +889,6 @@ public bool VariantDecode(out object res)
{
if (!Decode(out int arrLen)) { return false; }
if (arrLen < 0) { return false; }

int rank = 1;
if ((mask & 0x40) != 0)
{
if (!Decode(out rank)) { return false; }
}

Type type = GetNetType((VariantType)(mask & 0x3F));

var arr = Array.CreateInstance(type, arrLen);
Expand All @@ -914,6 +907,8 @@ public bool VariantDecode(out object res)
// Decoding multidimensional arrays is not supported, decode as a flat array.
if ((mask & 0x40) != 0)
{
if (!Decode(out int rank)) { return false; }

for (int i = 0; i < rank; i++)
{
if (!Decode(out int _)) { return false; }
Expand Down
1 change: 0 additions & 1 deletion NET Core/LibUA/MemoryBufferExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1183,7 +1183,6 @@ public static bool Decode(this MemoryBuffer mem, out DataValue dv)
Int64 serverTimestamp = 0;
bool hasStatusCode = false, hasSourceTimestamp = false, hasServerTimestamp = false;


if (!mem.Decode(out byte mask)) { return false; }

if ((mask & 1) != 0)
Expand Down
1 change: 0 additions & 1 deletion NET Core/TestClient/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,6 @@ private static void Main(string[] args)
var securityPolicy = SecurityPolicy.Basic256Sha256;
bool useAnonymousUser = true;


client.Connect();
client.OpenSecureChannel(MessageSecurityMode.None, SecurityPolicy.None, null);
client.FindServers(out ApplicationDescription[] appDescs, new[] { "en" });
Expand Down
8 changes: 2 additions & 6 deletions NET/LibUA/Encoding.cs
Original file line number Diff line number Diff line change
Expand Up @@ -890,12 +890,6 @@ public bool VariantDecode(out object res)
if (!Decode(out int arrLen)) { return false; }
if (arrLen < 0) { return false; }

int rank = 1;
if ((mask & 0x40) != 0)
{
if (!Decode(out rank)) { return false; }
}

Type type = GetNetType((VariantType)(mask & 0x3F));

var arr = Array.CreateInstance(type, arrLen);
Expand All @@ -914,6 +908,8 @@ public bool VariantDecode(out object res)
// Decoding multidimensional arrays is not supported, decode as a flat array.
if ((mask & 0x40) != 0)
{
if (!Decode(out int rank)) { return false; }

for (int i = 0; i < rank; i++)
{
if (!Decode(out int _)) { return false; }
Expand Down
1 change: 0 additions & 1 deletion NET/LibUA/MemoryBufferExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -776,7 +776,6 @@ public static bool Decode(this MemoryBuffer mem, out DataValue dv)
Int64 serverTimestamp = 0;
bool hasStatusCode = false, hasSourceTimestamp = false, hasServerTimestamp = false;


if (!mem.Decode(out byte mask)) { return false; }

if ((mask & 1) != 0)
Expand Down

0 comments on commit cef29f8

Please sign in to comment.