summaryrefslogtreecommitdiffhomepage
path: root/packet/bgp.go
diff options
context:
space:
mode:
Diffstat (limited to 'packet/bgp.go')
-rw-r--r--packet/bgp.go8
1 files changed, 7 insertions, 1 deletions
diff --git a/packet/bgp.go b/packet/bgp.go
index 01de6a62..c3e3c045 100644
--- a/packet/bgp.go
+++ b/packet/bgp.go
@@ -1959,7 +1959,7 @@ func flowSpecTcpFlagParser(args []string) (FlowSpecComponentInterface, error) {
}
func flowSpecNumericParser(args []string) (FlowSpecComponentInterface, error) {
- exp := regexp.MustCompile("^((<=|>=|[<>=])(\\d+)&)?(<=|>=|[<>=])(\\d+)$")
+ exp := regexp.MustCompile("^((<=|>=|[<>=])(\\d+)&)?(<=|>=|[<>=])?(\\d+)$")
items := make([]*FlowSpecComponentItem, 0)
f := func(and bool, o, v string) *FlowSpecComponentItem {
@@ -1967,6 +1967,9 @@ func flowSpecNumericParser(args []string) (FlowSpecComponentInterface, error) {
if and {
op |= 0x40
}
+ if len(o) == 0 {
+ op |= 0x1
+ }
for _, oo := range o {
switch oo {
case '>':
@@ -1987,6 +1990,9 @@ func flowSpecNumericParser(args []string) (FlowSpecComponentInterface, error) {
for _, arg := range args[1:] {
var and bool
elems := exp.FindStringSubmatch(arg)
+ if len(elems) == 0 {
+ return nil, fmt.Errorf("invalid flowspec numeric item")
+ }
if elems[1] != "" {
and = true
items = append(items, f(false, elems[2], elems[3]))