Skip to content

Commit 2989002

Browse files
Libcalico-go: Prevent segfault when network/ip is not valid
1 parent f4c5ef0 commit 2989002

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

libcalico-go/lib/backend/model/rule.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,9 @@ func (r Rule) AllNotDstNets() []*net.IPNet {
130130
func joinNets(nets []*net.IPNet) string {
131131
parts := make([]string, len(nets))
132132
for i, n := range nets {
133-
parts[i] = n.String()
133+
if n != nil {
134+
parts[i] = n.String()
135+
}
134136
}
135137
return strings.Join(parts, ",")
136138
}

libcalico-go/lib/backend/syncersv1/updateprocessors/rules.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -278,7 +278,9 @@ func NormalizeIPNets(nets []string) []*cnet.IPNet {
278278
}
279279
out := make([]*cnet.IPNet, len(nets))
280280
for i, n := range nets {
281-
out[i] = normalizeIPNet(n)
281+
if x := normalizeIPNet(n); x != nil {
282+
out[i] = x
283+
}
282284
}
283285
return out
284286
}

0 commit comments

Comments
 (0)