From 634c408903fffd5f4a13016cf29d23cb652cf3d0 Mon Sep 17 00:00:00 2001 From: ISHIDA Wataru Date: Tue, 22 Dec 2015 16:16:47 +0900 Subject: packet: fix insufficient length check Signed-off-by: ISHIDA Wataru --- packet/bgp.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'packet/bgp.go') diff --git a/packet/bgp.go b/packet/bgp.go index 61d36e4b..1cece5e5 100644 --- a/packet/bgp.go +++ b/packet/bgp.go @@ -5938,10 +5938,10 @@ type PathAttributeUnknown struct { } func GetPathAttribute(data []byte) (PathAttributeInterface, error) { - if len(data) < 1 { + if len(data) < 2 { eCode := uint8(BGP_ERROR_UPDATE_MESSAGE_ERROR) - eSubCode := uint8(BGP_ERROR_SUB_MALFORMED_ATTRIBUTE_LIST) - return nil, NewMessageError(eCode, eSubCode, nil, "attribute type length is short") + eSubCode := uint8(BGP_ERROR_SUB_ATTRIBUTE_LENGTH_ERROR) + return nil, NewMessageError(eCode, eSubCode, data, "attribute type length is short") } switch BGPAttrType(data[1]) { case BGP_ATTR_TYPE_ORIGIN: -- cgit v1.2.3