diff options
author | ISHIDA Wataru <ishida.wataru@lab.ntt.co.jp> | 2016-05-18 13:00:17 +0000 |
---|---|---|
committer | ISHIDA Wataru <ishida.wataru@lab.ntt.co.jp> | 2016-05-18 13:07:40 +0000 |
commit | c2bb04d5efa1c7586500832e16524e13596dbe29 (patch) | |
tree | 52c750910bdfd71acc23f49755ef3cc965a03aac | |
parent | 1c50e56b7ac74287531142f7ecf55183a7ca8b66 (diff) |
packet/bgp: add error handling in flowSpecIpProtoParser()
Signed-off-by: ISHIDA Wataru <ishida.wataru@lab.ntt.co.jp>
-rw-r--r-- | packet/bgp/bgp.go | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/packet/bgp/bgp.go b/packet/bgp/bgp.go index b0147a10..4fd0898e 100644 --- a/packet/bgp/bgp.go +++ b/packet/bgp/bgp.go @@ -2210,6 +2210,9 @@ func flowSpecIpProtoParser(rf RouteFamily, args []string) (FlowSpecComponentInte protos := strings.Join(ss, "|") exp := regexp.MustCompile(fmt.Sprintf("^%s (((%s) )*)(%s)$", FlowSpecNameMap[FLOW_SPEC_TYPE_IP_PROTO], protos, protos)) elems := exp.FindStringSubmatch(strings.Join(args, " ")) + if len(elems) < 2 { + return nil, fmt.Errorf("invalid ip-proto format") + } items := make([]*FlowSpecComponentItem, 0) eq := 0x1 if elems[1] != "" { |