diff options
author | Ilya Etingof <etingof@gmail.com> | 2019-07-20 00:41:49 +0200 |
---|---|---|
committer | Ilya Etingof <etingof@gmail.com> | 2019-07-26 08:57:23 +0200 |
commit | 43cd9ab639a432c42c783f06772b4f3981b80c83 (patch) | |
tree | e9ce30c50ca3060e0fb5d68fee534521db7a77a9 | |
parent | 90d7826ce1d1fa643d7434ec855cf51fb219014c (diff) | |
download | pysnmp-git-43cd9ab639a432c42c783f06772b4f3981b80c83.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 | 26 |
2 files changed, 14 insertions, 14 deletions
diff --git a/CHANGES.txt b/CHANGES.txt index 8ed4fe9b..4933e9b4 100644 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -110,6 +110,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 de5a5fdb..76fb3ee5 100644 --- a/pysnmp/proto/proxy/rfc2576.py +++ b/pysnmp/proto/proxy/rfc2576.py @@ -148,30 +148,28 @@ def v1ToV2(v1Pdu, origV2Pdu=None, snmpTrapCommunity=''): v2VarBinds.append( (oid, V1_TO_V2_VALUE_MAP[v1Val.tagSet].clone(v1Val))) - if pduType in rfc3411.RESPONSE_CLASS_PDUS: - # 4.1.2.2.1&2 + if pduType not in rfc3411.NOTIFICATION_CLASS_PDUS: 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.RESPONSE_CLASS_PDUS: + # 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) v2c.apiPDU.setErrorIndex(v2Pdu, errorIndex) - # 4.1.2.1 --> no-op + v2c.apiPDU.setRequestID(v2Pdu, int(v1.apiPDU.getRequestID(v1Pdu))) - elif pduType in rfc3411.CONFIRMED_CLASS_PDUS: - v2c.apiPDU.setErrorStatus(v2Pdu, 0) - v2c.apiPDU.setErrorIndex(v2Pdu, 0) + # 4.1.2.1 --> no-op - if pduType not in rfc3411.NOTIFICATION_CLASS_PDUS: - v2c.apiPDU.setRequestID(v2Pdu, int(v1.apiPDU.getRequestID(v1Pdu))) + else: + v2c.apiPDU.setDefaults(v2Pdu) v2c.apiPDU.setVarBinds(v2Pdu, v2VarBinds) |