Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

JsonDecoder throws unexpected ArgumentOutOfRange exception #2887

Open
1 of 5 tasks
mregen opened this issue Dec 6, 2024 · 1 comment
Open
1 of 5 tasks

JsonDecoder throws unexpected ArgumentOutOfRange exception #2887

mregen opened this issue Dec 6, 2024 · 1 comment

Comments

@mregen
Copy link
Contributor

mregen commented Dec 6, 2024

Type of issue

  • Bug
  • Enhancement
  • Compliance
  • Question
  • Help wanted

Current Behavior

System.Private.CoreLib.dll!System.String.ThrowSubstringArgumentOutOfRange(Int32, Int32)+0x42 [/_/src/libraries/System.Private.CoreLib/src/System/String.Manipulation.cs @ 2083]
System.Private.CoreLib.dll!System.String.Substring(Int32)+0x3a [/_/src/libraries/System.Private.CoreLib/src/System/String.Manipulation.cs @ 2044]
Opc.Ua.Core.dll!Opc.Ua.NodeId.Parse(Opc.Ua.IServiceMessageContext, System.String, Opc.Ua.NodeIdParsingOptions)+0x607
Opc.Ua.Core.dll!Opc.Ua.JsonDecoder.ReadNodeId(System.String)+0x198
Opc.Ua.Core.dll!Opc.Ua.JsonDecoder.ReadNodeIdArray(System.String)+0x100
Opc.Ua.Core.dll!Opc.Ua.JsonDecoder.ReadVariantArrayBody(System.String, Opc.Ua.BuiltInType)+0x700
Opc.Ua.Core.dll!Opc.Ua.JsonDecoder.ReadVariant(System.String)+0x263
Opc.Ua.Core.dll!Opc.Ua.JsonDecoder.ReadDataValue(System.String)+0x127
Opc.Ua.Core.dll!Opc.Ua.JsonDecoder.ReadDataValueArray(System.String)+0x100
Opc.Ua.Core.dll!Opc.Ua.ReadResponse.Decode(Opc.Ua.IDecoder)+0x108
Opc.Ua.Core.dll!Opc.Ua.JsonDecoder.ReadEncodeable(System.String, System.Type, Opc.Ua.ExpandedNodeId)+0x2b6
Opc.Ua.Core.dll!Opc.Ua.JsonDecoder.DecodeMessage(System.Type)+0x3cf

one more in QualifiedName.Parse

Opc.Ua.Core.dll!Opc.Ua.QualifiedName.Parse(Opc.Ua.IServiceMessageContext, System.String, Boolean)+0x478
Opc.Ua.Core.dll!Opc.Ua.JsonDecoder.ReadQualifiedName(System.String)+0x12d
Opc.Ua.Core.dll!Opc.Ua.JsonDecoder.ReadVariantBody(System.String, Opc.Ua.BuiltInType)+0x9d7
Opc.Ua.Core.dll!Opc.Ua.JsonDecoder.ReadVariant(System.String)+0x29a
Opc.Ua.Core.dll!Opc.Ua.JsonDecoder.ReadDataValue(System.String)+0x127
Opc.Ua.Core.dll!Opc.Ua.JsonDecoder.ReadDataValueArray(System.String)+0x100
Opc.Ua.Core.dll!Opc.Ua.ReadResponse.Decode(Opc.Ua.IDecoder)+0x108
Opc.Ua.Core.dll!Opc.Ua.JsonDecoder.ReadEncodeable(System.String, System.Type, Opc.Ua.ExpandedNodeId)+0x2b6
Opc.Ua.Core.dll!Opc.Ua.JsonDecoder.DecodeMessage(System.Type)+0x3cf

Expected Behavior

throw ServiceResultException with BadDecodingError

Steps To Reproduce

  • create JsonPubsub message with invalid input NodeId, e.g. "ns=1;s="

Environment

- OS:
- Environment:
- Runtime:
- Nuget Version: 1.5.374.126
- Component:
- Server:
- Client:

Anything else?

No response

@mregen
Copy link
Contributor Author

mregen commented Dec 7, 2024

There is a Substring call with a hardcoded offset 2, the remaining length should be checked before calling it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant