diff options
author | tb <> | 2023-11-06 14:50:12 +0000 |
---|---|---|
committer | tb <> | 2023-11-06 14:50:12 +0000 |
commit | d5eb0b2385353ece628a52716839606ed60399a8 (patch) | |
tree | 49f4ffb702f23c4caf1482fa6822f299b40c521d | |
parent | 88009dabc2099fe0214bf73b478c04eacfaca42a (diff) | |
download | openbsd-d5eb0b2385353ece628a52716839606ed60399a8.tar.gz openbsd-d5eb0b2385353ece628a52716839606ed60399a8.tar.bz2 openbsd-d5eb0b2385353ece628a52716839606ed60399a8.zip |
Fix a for loop bug introduced in the concurrency refactor
Due to Go's idiosyncratic semantics of for loops, tests would only run
some of the test groups in the JSON file because by the time the closure
is called, the array index could be changed. For example, on fast 8 core
machines, the CMAC tests would run the last test group with key size 320
eight times rather than each of the eight test groups once.
Make a copy of the pointer before passing it to the closure to avoid this
issue.
Simpler version of my initial fix from jsing
-rw-r--r-- | src/regress/lib/libcrypto/wycheproof/wycheproof.go | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/src/regress/lib/libcrypto/wycheproof/wycheproof.go b/src/regress/lib/libcrypto/wycheproof/wycheproof.go index fa03192161..7994e13879 100644 --- a/src/regress/lib/libcrypto/wycheproof/wycheproof.go +++ b/src/regress/lib/libcrypto/wycheproof/wycheproof.go | |||
@@ -1,4 +1,4 @@ | |||
1 | /* $OpenBSD: wycheproof.go,v 1.146 2023/11/06 14:43:02 tb Exp $ */ | 1 | /* $OpenBSD: wycheproof.go,v 1.147 2023/11/06 14:50:12 tb Exp $ */ |
2 | /* | 2 | /* |
3 | * Copyright (c) 2018 Joel Sing <jsing@openbsd.org> | 3 | * Copyright (c) 2018 Joel Sing <jsing@openbsd.org> |
4 | * Copyright (c) 2018,2019,2022 Theo Buehler <tb@openbsd.org> | 4 | * Copyright (c) 2018,2019,2022 Theo Buehler <tb@openbsd.org> |
@@ -2771,7 +2771,8 @@ func runTestVectors(path string, variant testVariant) bool { | |||
2771 | wtv.Algorithm, wtv.NumberOfTests, filepath.Base(path)) | 2771 | wtv.Algorithm, wtv.NumberOfTests, filepath.Base(path)) |
2772 | 2772 | ||
2773 | success := true | 2773 | success := true |
2774 | for i := range wtv.TestGroups { | 2774 | for _, tg := range wtv.TestGroups { |
2775 | testGroupJSON := tg | ||
2775 | testc.runTest(func() bool { | 2776 | testc.runTest(func() bool { |
2776 | var wtg interface{} | 2777 | var wtg interface{} |
2777 | switch wtv.Algorithm { | 2778 | switch wtv.Algorithm { |
@@ -2826,7 +2827,7 @@ func runTestVectors(path string, variant testVariant) bool { | |||
2826 | return false | 2827 | return false |
2827 | } | 2828 | } |
2828 | 2829 | ||
2829 | if err := json.Unmarshal(wtv.TestGroups[i], wtg); err != nil { | 2830 | if err := json.Unmarshal(testGroupJSON, wtg); err != nil { |
2830 | log.Fatalf("Failed to unmarshal test groups JSON: %v", err) | 2831 | log.Fatalf("Failed to unmarshal test groups JSON: %v", err) |
2831 | } | 2832 | } |
2832 | switch wtv.Algorithm { | 2833 | switch wtv.Algorithm { |