diff options
author | Ilya Etingof <etingof@gmail.com> | 2019-07-20 00:41:49 +0200 |
---|---|---|
committer | Ilya Etingof <etingof@gmail.com> | 2019-07-20 00:41:49 +0200 |
commit | 0228371e12b4a19a6b4942626924f8040a92f4cd (patch) | |
tree | 18932be5d306768adf7f7509c04e2a9c5c4e461f | |
parent | d75f2fdb4c147d29bed33bacc03466455908d2f8 (diff) | |
download | pysnmp-git-0228371e12b4a19a6b4942626924f8040a92f4cd.tar.gz |
Fix TRAP PDU proxy translation
Fixed crash on uninitialized component serialization left out in
SNMP v1 TRAP PDU to SNMPv2/3 TRAP PDU translation routine.
-rw-r--r-- | CHANGES.txt | 2 | ||||
-rw-r--r-- | pysnmp/proto/proxy/rfc2576.py | 24 |
2 files changed, 14 insertions, 12 deletions
diff --git a/CHANGES.txt b/CHANGES.txt index 778ed8a7..3a1efbb6 100644 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -10,6 +10,8 @@ Revision 4.4.10, released 2019-04-XX - Fixed `var-bindings` initialization to prevent pyasn1 encoder failures with newer pyasn1 versions where `SequenceOf` type looses its default initializer. +- Fixed crash on uninitialized component serialization left out in + SNMP v1 TRAP PDU to SNMPv2/3 TRAP PDU proxy translation routine. Revision 4.4.9, released 2019-02-09 ----------------------------------- diff --git a/pysnmp/proto/proxy/rfc2576.py b/pysnmp/proto/proxy/rfc2576.py index 6b1dfcbb..7b20ddc9 100644 --- a/pysnmp/proto/proxy/rfc2576.py +++ b/pysnmp/proto/proxy/rfc2576.py @@ -142,15 +142,17 @@ def v1ToV2(v1Pdu, origV2Pdu=None, snmpTrapCommunity=''): (oid, __v1ToV2ValueMap[v1Val.tagSet].clone(v1Val)) ) - if pduType in rfc3411.responseClassPDUs: - # 4.1.2.2.1&2 + if pduType not in rfc3411.notificationClassPDUs: errorStatus = int(v1.apiPDU.getErrorStatus(v1Pdu)) errorIndex = int(v1.apiPDU.getErrorIndex(v1Pdu, muteErrors=True)) - if errorStatus == 2: # noSuchName - if origV2Pdu.tagSet == v2c.GetNextRequestPDU.tagSet: - v2VarBinds = [(o, rfc1905.endOfMibView) for o, v in v2VarBinds] - else: - v2VarBinds = [(o, rfc1905.noSuchObject) for o, v in v2VarBinds] + + if pduType in rfc3411.responseClassPDUs: + # 4.1.2.2.1&2 + if errorStatus == 2: # noSuchName + if origV2Pdu.tagSet == v2c.GetNextRequestPDU.tagSet: + v2VarBinds = [(o, rfc1905.endOfMibView) for o, v in v2VarBinds] + else: + v2VarBinds = [(o, rfc1905.noSuchObject) for o, v in v2VarBinds] # partial one-to-one mapping - 4.2.1 v2c.apiPDU.setErrorStatus(v2Pdu, errorStatus) @@ -158,13 +160,11 @@ def v1ToV2(v1Pdu, origV2Pdu=None, snmpTrapCommunity=''): # 4.1.2.1 --> no-op - elif pduType in rfc3411.confirmedClassPDUs: - v2c.apiPDU.setErrorStatus(v2Pdu, 0) - v2c.apiPDU.setErrorIndex(v2Pdu, 0) - - if pduType not in rfc3411.notificationClassPDUs: v2c.apiPDU.setRequestID(v2Pdu, int(v1.apiPDU.getRequestID(v1Pdu))) + else: + v2c.apiPDU.setDefaults(v2Pdu) + v2c.apiPDU.setVarBinds(v2Pdu, v2VarBinds) debug.logger & debug.flagPrx and debug.logger('v1ToV2: v2Pdu %s' % v2Pdu.prettyPrint()) |