Skip to content

SNMP GetResponse with non-minimal INTEGER request-id causes exception (extra 0xFF sign byte) #700

@KarloX2

Description

@KarloX2

Hello,

we are seeing an exception in SharpSNMP when receiving an SNMP GetResponse whose request-id INTEGER is BER-encoded with a non-minimal length.

Example from a real capture:

Request Id in my own GetRequest (correctly created with sharpsnmplib): 02 04 FB 6A 65 17

Request Id in the received GetResponse (causes the exception): 02 05 FF FB 6A 65 17

The numeric value of the request-id is identical, but the response includes an extra leading 0xFF sign-extension byte, making the INTEGER non-canonical. This violates BER minimal encoding rules, but the value itself is unambiguous and accepted by other SNMP implementations. I have no control over the agent software, so I'm unable to change the behavior on their side.

Questions:

  • Is this strict behavior intentional?
  • Would you consider accepting non-minimal INTEGER encodings for request-id (possibly behind a tolerance/compatibility option)?
  • If not, is there a recommended workaround at the application level?

Thanks for your guidance.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions