From 06d8564273a1ca5c5cc98aae5d6c724a7033ca49 Mon Sep 17 00:00:00 2001 From: Kevin Heifner Date: Wed, 6 Dec 2023 07:25:07 -0600 Subject: [PATCH] GH-1953 return failure when n==0 --- libraries/chain/webassembly/crypto.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/libraries/chain/webassembly/crypto.cpp b/libraries/chain/webassembly/crypto.cpp index fb99fae07f..470cc3b28a 100644 --- a/libraries/chain/webassembly/crypto.cpp +++ b/libraries/chain/webassembly/crypto.cpp @@ -284,7 +284,7 @@ namespace eosio { namespace chain { namespace webassembly { } int32_t interface::bls_g1_weighted_sum(span points, span scalars, const uint32_t n, span result) const { - if(points.size() != n*96 || scalars.size() != n*32 || result.size() != 96) + if(n == 0 || points.size() != n*96 || scalars.size() != n*32 || result.size() != 96) return return_code::failure; // Use much efficient scale for the special case of n == 1. @@ -319,7 +319,7 @@ namespace eosio { namespace chain { namespace webassembly { } int32_t interface::bls_g2_weighted_sum(span points, span scalars, const uint32_t n, span result) const { - if(points.size() != n*192 || scalars.size() != n*32 || result.size() != 192) + if(n == 0 || points.size() != n*192 || scalars.size() != n*32 || result.size() != 192) return return_code::failure; // Use much efficient scale for the special case of n == 1. @@ -354,7 +354,7 @@ namespace eosio { namespace chain { namespace webassembly { } int32_t interface::bls_pairing(span g1_points, span g2_points, const uint32_t n, span result) const { - if(g1_points.size() != n*96 || g2_points.size() != n*192 || result.size() != 576) + if(n == 0 || g1_points.size() != n*96 || g2_points.size() != n*192 || result.size() != 576) return return_code::failure; std::vector> v; v.reserve(n);