diff --git a/pkg/yqlib/operator_multiply_test.go b/pkg/yqlib/operator_multiply_test.go index 2c31b6f9..66256c92 100644 --- a/pkg/yqlib/operator_multiply_test.go +++ b/pkg/yqlib/operator_multiply_test.go @@ -2,6 +2,7 @@ package yqlib import ( "fmt" + "math/bits" "strings" "testing" ) @@ -707,11 +708,13 @@ var multiplyOperatorScenarios = []expressionScenario{ expectedError: "result of repeating string (1 bytes) by 99999999 would exceed 10485760 bytes", }, { - // The size guard must not overflow: len * count can wrap to - // a negative or small value on 64-bit, bypassing the check. + // Pick a count whose product with len("ab") overflows int on + // any architecture: 2^30 on 32-bit, 2^62 on 64-bit. Doubling + // either yields MaxInt+1, which wraps to MinInt and bypasses + // a naive len*count guard. skipDoc: true, - expression: `"ab" * 4611686018427387904`, - expectedError: "result of repeating string (2 bytes) by 4611686018427387904 would exceed 10485760 bytes", + expression: fmt.Sprintf(`"ab" * %d`, 1<<(bits.UintSize-2)), + expectedError: fmt.Sprintf("result of repeating string (2 bytes) by %d would exceed 10485760 bytes", 1<<(bits.UintSize-2)), }, }