Skip to content

Commit

Permalink
r/host_virtual_switch: Assert exactly 3 elements in ID
Browse files Browse the repository at this point in the history
SplitN should always give 3 elements on a proper ID.
  • Loading branch information
vancluever committed Aug 31, 2017
1 parent 26ce39a commit f5bd248
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion vsphere/host_virtual_switch_structure.go
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ func saveHostVirtualSwitchID(d *schema.ResourceData, hsID, name string) {
// name.
func splitHostVirtualSwitchID(raw string) (string, string, error) {
s := strings.SplitN(raw, ":", 3)
if len(s) < 3 || s[0] != hostVirtualSwitchIDPrefix || s[1] == "" || s[2] == "" {
if len(s) != 3 || s[0] != hostVirtualSwitchIDPrefix || s[1] == "" || s[2] == "" {
return "", "", fmt.Errorf("corrupt ID: %s", raw)
}
return s[1], s[2], nil
Expand Down

0 comments on commit f5bd248

Please sign in to comment.