From 0946b46a40af5bdcc328544fa07555ab5df83733 Mon Sep 17 00:00:00 2001 From: Martin Proffitt Date: Sat, 25 May 2024 12:30:57 +0200 Subject: [PATCH] Fix segmentation fault in cidrsubnets function This change is necessary to prevent the cidrsubnets function segfaulting when overflowing the available range fixes: https://github.com/upbound/function-cidr/issues/30 --- fn.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/fn.go b/fn.go index a7500b4..122a18b 100644 --- a/fn.go +++ b/fn.go @@ -177,8 +177,8 @@ func (f *Function) RunFunction(_ context.Context, req *fnv1beta1.RunFunctionRequ return rsp, nil } } - cidrs, cidrSubnetsErr := CidrSubnets(prefix, newBits...) - if cidrSubnetsErr != nil { + cidrs, err := CidrSubnets(prefix, newBits...) + if err != nil { response.Fatal(rsp, errors.Wrapf(err, "cannot calculate Subnet CIDRs for %s", oxr.Resource.GetKind())) return rsp, nil }