Skip to content

Commit fc2a426

Browse files
committed
fix: off-by-one bounds check
Correct an off-by-one bounds check in `parseParameter` (`builder/vmware/common/driver_parser.go`). The condition previously used `idxAddress+1 > len(val.operand)`, which could miss the single-operand case and risk an out-of-range access. Changed to `idxAddress+1 >= len(val.operand)` so a single address is correctly parsed as a p`ParameterRange4` with `min == max`. Signed-off-by: Ryan Johnson <ryan.johnson@broadcom.com>
1 parent f50d79b commit fc2a426

1 file changed

Lines changed: 2 additions & 2 deletions

File tree

builder/vmware/common/driver_parser.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -681,7 +681,7 @@ func parseParameter(val tkParameter) (pParameter, error) {
681681
return nil, fmt.Errorf("invalid number of parameters for pParameterRange : %v", val.operand)
682682
}
683683

684-
if idxAddress+1 > len(val.operand) {
684+
if idxAddress+1 >= len(val.operand) {
685685
res := net.ParseIP(val.operand[idxAddress])
686686
return pParameterRange4{min: res, max: res}, nil
687687
}
@@ -2337,7 +2337,7 @@ func readDhcpdLeaseEntry(in chan byte) (entry *dhcpLeaseEntry, err error) {
23372337
// means that we should probably bail.
23382338
return &dhcpLeaseEntry{address: matches[1]}, fmt.Errorf("missing parameters for lease entry %v", matches[1])
23392339

2340-
} else if !ok {
2340+
} else {
23412341
// If our channel is closed, so we bail "cleanly".
23422342
return nil, nil
23432343
}

0 commit comments

Comments
 (0)