Skip to content

Commit 434fa1b

Browse files
filanovclaude
andcommitted
fix(plugin): check trunk id instead of minID in bounds validation
The condition was comparing minID against 4096 instead of the actual id value, allowing out-of-range individual trunk IDs to slip through undetected. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> Signed-off-by: Michael Filanov <mfilanov@nvidia.com>
1 parent c5cade4 commit 434fa1b

2 files changed

Lines changed: 7 additions & 1 deletion

File tree

pkg/plugin/plugin.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -237,7 +237,7 @@ func SplitVlanIds(trunks []*types.Trunk) ([]uint, error) {
237237
var id uint
238238
if item.ID != nil {
239239
id = *item.ID
240-
if minID > 4096 {
240+
if id > 4096 {
241241
return nil, errors.New("incorrect trunk id parameter")
242242
}
243243
vlans[id] = true

tests/cni/plugin_test.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -972,6 +972,12 @@ var pluginTestFunc = func(version string) {
972972
testSplitVlanIds(trunks, nil, errors.New("incorrect trunk maxID parameter"), false)
973973
})
974974
})
975+
Context("specify trunk with id greater than 4096", func() {
976+
trunks := `[ {"id": 15}, {"id": 5000} ]`
977+
It("testSplitVlanIds method should throw appropriate error", func() {
978+
testSplitVlanIds(trunks, nil, errors.New("incorrect trunk id parameter"), false)
979+
})
980+
})
975981
})
976982
}
977983

0 commit comments

Comments
 (0)