Add safe_cast (RIPD-1702):

This change ensures that no overflow can occur when casting
between enums and integral types.
This commit is contained in:
Howard Hinnant
2018-12-21 17:13:58 -05:00
committed by Nik Bougalis
parent 494724578a
commit 148bbf4e8f
35 changed files with 213 additions and 86 deletions

View File

@@ -17,6 +17,7 @@
*/
//==============================================================================
#include <ripple/basics/safe_cast.h>
#include <ripple/server/Port.h>
#include <ripple/beast/rfc2616.h>
#include <ripple/beast/core/LexicalCast.h>
@@ -192,7 +193,7 @@ parse_Port (ParsedPort& port, Section const& section, std::ostream& log)
{
try
{
port.limit = static_cast<int> (
port.limit = safe_cast<int> (
beast::lexicalCastThrow<std::uint16_t>(lim));
}
catch (std::exception const&)