Skip to content

Commit

Permalink
Check op limits on Variant arrays and TranslateBrowsePathsToNodeIds (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
mrsuciu committed May 5, 2022
1 parent 586a63c commit ae9bf1b
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
5 changes: 5 additions & 0 deletions Libraries/Opc.Ua.Server/Server/StandardServer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -991,6 +991,11 @@ public override ResponseHeader UnregisterNodes(RequestHeader requestHeader, Node
{
ValidateOperationLimits(browsePaths, OperationLimits.MaxNodesPerTranslateBrowsePathsToNodeIds);

foreach (BrowsePath bp in browsePaths)
{
ValidateOperationLimits(bp.RelativePath.Elements.Count, OperationLimits.MaxNodesPerTranslateBrowsePathsToNodeIds);
}

m_serverInternal.NodeManager.TranslateBrowsePathsToNodeIds(
context,
browsePaths,
Expand Down
11 changes: 10 additions & 1 deletion Stack/Opc.Ua.Core/Types/Encoders/BinaryDecoder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1522,6 +1522,15 @@ public object ReadArray(string fieldName, int valueRank, BuiltInType builtInType
}
length *= dimensions[ii];
}
if (length > m_context.MaxArrayLength)
{
throw ServiceResultException.Create(
StatusCodes.BadEncodingLimitsExceeded,
"Maximum array length of {0} was exceeded while summing up to {1} from the array dimensions",
m_context.MaxArrayLength,
length
);
}
// read the elements
Array elements = null;
if (encodeableTypeId != null)
Expand Down Expand Up @@ -2151,7 +2160,7 @@ private Variant ReadVariantValue(string fieldName)
if ((encodingByte & (byte)VariantArrayEncodingBits.Array) != 0)
{
// read the array length.
int length = m_reader.ReadInt32();
int length = ReadArrayLength();

if (length < 0)
{
Expand Down

0 comments on commit ae9bf1b

Please sign in to comment.