diff options
author | FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp> | 2015-01-23 22:15:26 +0900 |
---|---|---|
committer | FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp> | 2015-01-23 22:15:26 +0900 |
commit | 3aced1df03476d01939b7739152728b18825f56d (patch) | |
tree | 05cceb893fde58fcfcfd28e98d208febb7618197 /packet | |
parent | b85f6ccfec193fe629171fd2241399a13cace7da (diff) |
packet: fix length check about type conversion
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
Diffstat (limited to 'packet')
-rw-r--r-- | packet/bgp.go | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/packet/bgp.go b/packet/bgp.go index da15c9bf..a3bee84d 100644 --- a/packet/bgp.go +++ b/packet/bgp.go @@ -85,7 +85,7 @@ func (c *DefaultParameterCapability) Code() BGPCapabilityCode { func (c *DefaultParameterCapability) DecodeFromBytes(data []byte) error { c.CapCode = BGPCapabilityCode(data[0]) c.CapLen = data[1] - if uint8(len(data)) < 2+c.CapLen { + if len(data) < 2+int(c.CapLen) { return fmt.Errorf("Not all OptionParameterCapability bytes available") } c.CapValue = data[2 : 2+c.CapLen] @@ -379,7 +379,7 @@ func (msg *BGPOpen) DecodeFromBytes(data []byte) error { msg.ID = data[5:9] msg.OptParamLen = data[9] data = data[10:] - if uint8(len(data)) < msg.OptParamLen { + if len(data) < int(msg.OptParamLen) { return fmt.Errorf("Not all BGP Open message bytes available") } @@ -1878,7 +1878,7 @@ func (p *PathAttributeMpReachNLRI) DecodeFromBytes(data []byte) error { afi := binary.BigEndian.Uint16(value[0:2]) safi := value[2] nexthopLen := value[3] - if len(value) < 4 + int(nexthopLen) { + if len(value) < 4+int(nexthopLen) { return NewMessageError(eCode, eSubCode, value, "mpreach nexthop length is short") } nexthopbin := value[4 : 4+nexthopLen] |