From 2b04006b1e93db5b3ce098f45bb41e5aa270e8b3 Mon Sep 17 00:00:00 2001 From: Ayke van Laethem Date: Sun, 16 Oct 2022 16:09:07 +0200 Subject: [PATCH] main: fix USB vid/pid lookup I introduced a bug in #3207: looking up a VID/PID pair would result in a slice out of bounds panic. This is a trivial fix for that bug. --- main.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/main.go b/main.go index 662e7033..9fc75711 100644 --- a/main.go +++ b/main.go @@ -1028,11 +1028,11 @@ func getDefaultPort(portFlag string, usbInterfaces []string) (port string, err e if len(parts) != 2 { return "", fmt.Errorf("could not parse USB VID/PID pair %q", s) } - vid, err := strconv.ParseUint(parts[1], 16, 16) + vid, err := strconv.ParseUint(parts[0], 16, 16) if err != nil { return "", fmt.Errorf("could not parse USB vendor ID %q: %w", parts[1], err) } - pid, err := strconv.ParseUint(parts[2], 16, 16) + pid, err := strconv.ParseUint(parts[1], 16, 16) if err != nil { return "", fmt.Errorf("could not parse USB product ID %q: %w", parts[1], err) }