Skip to content

Commit

Permalink
Fix issue #12
Browse files Browse the repository at this point in the history
Incorrect packet size check for packets > 128
Check unnecessary as actual length came from BER.h which was from decoding the packet correctly.
  • Loading branch information
shortbloke committed Sep 2, 2021
1 parent 1fce429 commit 2adad9a
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 16 deletions.
12 changes: 8 additions & 4 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# CHANGELOG for SNMP Manager For ESP8266/ESP32/Arduino

## 1.1.4

- Fixes #12 where additional check for packet length was incorrect and unnecessary.

## 1.1.3

Focus: Increase robustness
Expand All @@ -13,11 +17,11 @@ Focus: Increase robustness

- Reduce max size of SNMP message on ESP8266 to address [reported issue](https://github.com/shortbloke/Broadband_Usage_Display/issues/4_) which triggered exception: `Exception 9: LoadStoreAlignmentCause: Load or store to an unaligned address`

# 1.1.1
## 1.1.1

- Improve OctetString handling for long stringds
- Improve OctetString handling for long strings
- Handle OID > 50 characters

# 1.1.0
## 1.1.0

- Initial library release
- Initial library release
2 changes: 1 addition & 1 deletion library.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name=SNMP Manager
version=1.1.3
version=1.1.4
author=Martin Rowan <martin@martinrowan.co.uk>
maintainer=Martin Rowan <martin@martinrowan.co.uk>
sentence=An SNMP Manager library to make SNMP requests to other SNMP enabled devices.
Expand Down
13 changes: 2 additions & 11 deletions src/SNMPGetResponse.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,19 +41,10 @@ bool SNMPGetResponse::parseFrom(unsigned char *buf)
}
SNMPPacket = new ComplexType(STRUCTURE); // ensure SNMPPacket is initialised to avoid crash in deconstructor
SNMPPacket->fromBuffer(buf);
int actualResponseLength = SNMPPacket->getLength();
int declaredResponseLength = buf[1]; // SNMP packet length value

if (actualResponseLength <= 30)
if (SNMPPacket->getLength() <= 30)
{
Serial.print(F("SNMP packet too short, needs to be > 30. Received only: "));
Serial.println(actualResponseLength);
return false;
}
if (declaredResponseLength != actualResponseLength)
{
Serial.printf("Packet Corrupt. Expected Payload size: %d - Actual size: %d\n", declaredResponseLength, actualResponseLength);
isCorrupt = true;
Serial.print(F("SNMP packet too short, needs to be > 30."));
return false;
}
// we now have a full ASN.1 packet in SNMPPacket
Expand Down

0 comments on commit 2adad9a

Please sign in to comment.