summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorFUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>2015-01-23 22:15:26 +0900
committerFUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>2015-01-23 22:15:26 +0900
commit3aced1df03476d01939b7739152728b18825f56d (patch)
tree05cceb893fde58fcfcfd28e98d208febb7618197
parentb85f6ccfec193fe629171fd2241399a13cace7da (diff)
packet: fix length check about type conversion
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
-rw-r--r--packet/bgp.go6
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]