Skip to content

Commit 1c7c696

Browse files
committed
Fix successfully unmarshalled nil raw result
Properly handle "null" as plugin output. This successfully unmarshals to a nil map, which crashes later when assigning confVersion to the map. Signed-off-by: Brad Davidson <[email protected]>
1 parent 812a8cf commit 1c7c696

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

Diff for: pkg/invoke/exec.go

+6
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,12 @@ func fixupResultVersion(netconf, result []byte) (string, []byte, error) {
5050
return "", nil, fmt.Errorf("failed to unmarshal raw result: %w", err)
5151
}
5252

53+
// plugin output of "null" is successfully unmarshalled, but results in a nil
54+
// map which causes a panic when the confVersion is assigned below.
55+
if rawResult == nil {
56+
rawResult = make(map[string]interface{})
57+
}
58+
5359
// Manually decode Result version; we need to know whether its cniVersion
5460
// is empty, while built-in decoders (correctly) substitute 0.1.0 for an
5561
// empty version per the CNI spec.

0 commit comments

Comments
 (0)