diff options
author | Maxim Polyakov <max.senia.poliak@gmail.com> | 2024-08-27 17:08:39 +0300 |
---|---|---|
committer | Felix Held <felix-coreboot@felixheld.de> | 2024-08-29 12:32:01 +0000 |
commit | 7f68483e281562f46f61304bc84efbd5fd5faf1b (patch) | |
tree | f269ceb69577be198f923eeb31353870bc195672 | |
parent | 00610d57fa853c4f5f1c7e50fca6ad3ecbbc08e9 (diff) |
util/hda-decoder: Protect 'fields' slice if empty string
This avoids panic if the file contains an empty string or an incorrect
configuration:
goroutine 1 [running]:
main.decodeFile({0x7ffd63da92a0?, 0xc000014070?}, 0x8?)
/path/to/coreboot/util/hda-decoder/main.go:72 +0x2ef
main.main()
/path/to/coreboot/util/hda-decoder/main.go:158 +0x2a5
Change-Id: I9ae8544e52d82e8d8a82a88a85a2de7d2f295ec1
Signed-off-by: Maxim Polyakov <max.senia.poliak@gmail.com>
Reviewed-on: https://review.coreboot.org/c/coreboot/+/84101
Reviewed-by: Felix Singer <service+coreboot-gerrit@felixsinger.de>
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Angel Pons <th3fanbus@gmail.com>
-rw-r--r-- | util/hda-decoder/main.go | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/util/hda-decoder/main.go b/util/hda-decoder/main.go index 83ddcbb43a..d686f19967 100644 --- a/util/hda-decoder/main.go +++ b/util/hda-decoder/main.go @@ -69,6 +69,11 @@ func decodeFile(path string, codec uint32) { for scanner.Scan() { fields := strings.Fields(scanner.Text()) + if len(fields) != 2 { + fmt.Print("// Something went wrong\n") + continue + } + pin := stringToUint32(fields[0]) config := stringToUint32(fields[1]) |