File tree Expand file tree Collapse file tree 2 files changed +9
-5
lines changed
Expand file tree Collapse file tree 2 files changed +9
-5
lines changed Original file line number Diff line number Diff line change @@ -60,6 +60,10 @@ var CidrNetmaskFunc = function.New(&function.Spec{
6060 return cty .UnknownVal (cty .String ), fmt .Errorf ("invalid CIDR expression: %s" , err )
6161 }
6262
63+ if network .IP .To4 () == nil {
64+ return cty .UnknownVal (cty .String ), fmt .Errorf ("IPv6 addresses cannot have a netmask: %s" , args [0 ].AsString ())
65+ }
66+
6367 return cty .StringVal (ipaddr .IP (network .Mask ).String ()), nil
6468 },
6569})
Original file line number Diff line number Diff line change @@ -118,11 +118,6 @@ func TestCidrNetmask(t *testing.T) {
118118 cty .StringVal ("0.0.0.0" ),
119119 false ,
120120 },
121- {
122- cty .StringVal ("1::/64" ),
123- cty .StringVal ("ffff:ffff:ffff:ffff::" ),
124- false ,
125- },
126121 {
127122 // We inadvertently inherited a pre-Go1.17 standard library quirk
128123 // if parsing zero-prefix parts as decimal rather than octal.
@@ -144,6 +139,11 @@ func TestCidrNetmask(t *testing.T) {
144139 cty .UnknownVal (cty .String ),
145140 true , // can't have an octet >255
146141 },
142+ {
143+ cty .StringVal ("1::/64" ),
144+ cty .UnknownVal (cty .String ),
145+ true , // IPv6 is invalid
146+ },
147147 }
148148
149149 for _ , test := range tests {
You can’t perform that action at this time.
0 commit comments