Skip to content

Commit dd24c63

Browse files
committed
update: fix int16 conversion with bounds check
1 parent 0031fee commit dd24c63

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

integration/model.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -235,6 +235,10 @@ func (c *IPVSConfig) NewIpvsServiceStruct(s *Service) (*ipvs.Service, error) {
235235
port = *c.Defaults.Port
236236
}
237237
}
238+
// Ensure the parsed port is within the valid range for uint16
239+
if port < 0 || port > 65535 {
240+
return nil, errors.New("port out of range")
241+
}
238242

239243
var protoAsNum uint16
240244
switch proto {
@@ -295,6 +299,10 @@ func (c *IPVSConfig) NewIpvsDestinationStruct(destination *Destination) (*ipvs.D
295299
p = *c.Defaults.Port
296300
}
297301
}
302+
// Ensure the parsed port is within the valid range for uint16
303+
if p < 0 || p > 65535 {
304+
return nil, errors.New("port out of range")
305+
}
298306

299307
df := destination.Forward
300308
if df == "" {

0 commit comments

Comments
 (0)