From c2bb04d5efa1c7586500832e16524e13596dbe29 Mon Sep 17 00:00:00 2001 From: ISHIDA Wataru Date: Wed, 18 May 2016 13:00:17 +0000 Subject: [PATCH] packet/bgp: add error handling in flowSpecIpProtoParser() Signed-off-by: ISHIDA Wataru --- packet/bgp/bgp.go | 3 +++ 1 file changed, 3 insertions(+) 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] != "" {