From 9e10683b88dfb26de9bcfaba16d202bb52183fc1 Mon Sep 17 00:00:00 2001 From: MITSUNARI Shigeo Date: Sat, 19 Mar 2016 23:14:36 +0900 Subject: [PATCH] check maxBitSize --- src/fp.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/fp.cpp b/src/fp.cpp index 1ee599b..6193634 100644 --- a/src/fp.cpp +++ b/src/fp.cpp @@ -378,6 +378,9 @@ static void initForMont(Op& op, const Unit *p, Mode mode) void Op::init(const std::string& mstr, int base, size_t maxBitSize, Mode mode) { + if (maxBitSize > MCL_MAX_OP_BIT_SIZE) { + throw cybozu::Exception("Op:init:too large maxBitSize") << maxBitSize << MCL_MAX_OP_BIT_SIZE; + } cybozu::disable_warning_unused_variable(mode); bool isMinus = fp::strToMpzArray(&bitSize, p, maxBitSize, mp, mstr, base); if (isMinus) throw cybozu::Exception("Op:init:mstr is minus") << mstr;