Skip to content

Commit

Permalink
Add length checks
Browse files Browse the repository at this point in the history
  • Loading branch information
job committed Jul 27, 2021
1 parent f82e338 commit d1a7ac3
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion cmd/stayrtr/stayrtr.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import (
"flag"
"fmt"
"io/ioutil"
"net"
"net/http"
"os"
"os/signal"
Expand Down Expand Up @@ -200,12 +201,22 @@ func processData(vrplistjson []prefixfile.VRPJson) ([]rtr.VRP, int, int, int) {
continue
}

count++
if prefix.IP.To4() != nil {
l, _ := net.IPMask.Size(prefix.Mask)
if (uint8(l) > v.Length || v.Length > 32) {
log.Errorf("%s Maxlength wrong: %d - %d", prefix, l, v.Length)
continue
}
countv4++
} else if prefix.IP.To16() != nil {
l, _ := net.IPMask.Size(prefix.Mask)
if (uint8(l) > v.Length || v.Length > 128) {
log.Errorf("%s Maxlength wrong: %d - %d", prefix, l, v.Length)
continue
}
countv6++
}
count++

key := fmt.Sprintf("%s,%d,%d", prefix, asn, v.Length)
_, exists := filterDuplicates[key]
Expand Down

0 comments on commit d1a7ac3

Please sign in to comment.