Skip to content

Commit 03d9261

Browse files
authored
marshal.go: stricter cursor bounds checking in unmarshalPayload (#384)
Stricter bounds checking for cursor in unmarshalPayload, to ensure it does not exceed or equals ``len(packet)``, preventinga panic when receiving a malformed packet. Special thanks to Amplia Security for disclosing this issue responsibly. Fixes #381 Signed-off-by: Tim Rots <tim.rots@protonmail.ch>
1 parent 98d8737 commit 03d9261

File tree

2 files changed

+2
-1
lines changed

2 files changed

+2
-1
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ number of octets as per ITU-T Rec. X.690 (07/2002).
1717
* [ENHANCEMENT] helper.go: Interpreting the value of an Opaque type as binary data if the Opaque sub-type cannot be recognized #374
1818
* [ENHANCEMENT] helper.go: Implemented Opaque type marshaling #374
1919
* [BUGFIX] marshal.go: Fixed invalid OpaqueFloat and OpaqueDouble marshaling in marshalVarbind() function #374
20+
* [BUGFIX] marshal.go: stricter cursor bounds checking in unmarshalPayload #384
2021

2122
## v1.33.0
2223

marshal.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1034,7 +1034,7 @@ func (x *GoSNMP) unmarshalPayload(packet []byte, cursor int, response *SnmpPacke
10341034
if len(packet) == 0 {
10351035
return errors.New("cannot unmarshal nil or empty payload packet")
10361036
}
1037-
if cursor > len(packet) {
1037+
if cursor >= len(packet) {
10381038
return fmt.Errorf("cannot unmarshal payload, packet length %d cursor %d", len(packet), cursor)
10391039
}
10401040
if response == nil {

0 commit comments

Comments
 (0)