summaryrefslogtreecommitdiffhomepage
path: root/packet/bmp.go
diff options
context:
space:
mode:
authorFUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>2015-11-19 16:17:23 -0800
committerFUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>2015-11-19 16:17:23 -0800
commit2b15188fe196bb2210ed4e24b776746469215318 (patch)
treedc8a043a81aa445e3318638c1ed813c3de0b70cf /packet/bmp.go
parentc130ea5b11da6974e5dda4613f771a418b05ce9b (diff)
bmp: fix ParseBMPMessage to handle failure of parsing header
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
Diffstat (limited to 'packet/bmp.go')
-rw-r--r--packet/bmp.go7
1 files changed, 5 insertions, 2 deletions
diff --git a/packet/bmp.go b/packet/bmp.go
index eceb1272..bc789c66 100644
--- a/packet/bmp.go
+++ b/packet/bmp.go
@@ -541,7 +541,10 @@ const (
func ParseBMPMessage(data []byte) (*BMPMessage, error) {
msg := &BMPMessage{}
- msg.Header.DecodeFromBytes(data)
+ err := msg.Header.DecodeFromBytes(data)
+ if err != nil {
+ return nil, err
+ }
data = data[BMP_HEADER_SIZE:msg.Header.Length]
switch msg.Header.Type {
@@ -564,7 +567,7 @@ func ParseBMPMessage(data []byte) (*BMPMessage, error) {
data = data[BMP_PEER_HEADER_SIZE:]
}
- err := msg.Body.ParseBody(msg, data)
+ err = msg.Body.ParseBody(msg, data)
if err != nil {
return nil, err
}