fix error handling in random.cpp and fix accidental openssl dependency

This commit is contained in:
arvidn 2017-01-16 09:50:56 -05:00 committed by Arvid Norberg
parent 748c6e0da0
commit 5736237a63
4 changed files with 10 additions and 5 deletions

View File

@ -62,7 +62,7 @@ namespace libtorrent { namespace aux {
if (ret != buffer.size())
{
#ifndef BOOST_NO_EXCEPTIONS
throw system_error(error_code(EIO, system_category()));
throw system_error(errors::no_entropy);
#else
std::terminate();
#endif

View File

@ -433,6 +433,9 @@ namespace libtorrent
overflow,
#endif
// random number generation failed
no_entropy = 200,
// the number of error codes
error_code_max
};

View File

@ -263,7 +263,11 @@ namespace libtorrent
"bencoded nesting depth exceeded",
"bencoded item count limit exceeded",
"integer overflow",
"",
"",
"",
#endif
"random number generator failed",
};
if (ev < 0 || ev >= int(sizeof(msgs)/sizeof(msgs[0])))
return "Unknown error";

View File

@ -41,13 +41,12 @@ POSSIBILITY OF SUCH DAMAGE.
#include "libtorrent/aux_/win_crypto_provider.hpp"
#elif defined TORRENT_USE_LIBCRYPTO
extern "C" {
#include <openssl/rand.h>
#include <openssl/err.h>
}
#include <boost/asio/ssl/error.hpp>
#endif
#include "libtorrent/aux_/disable_warnings_pop.hpp"
@ -98,8 +97,7 @@ namespace libtorrent
if (r != 1)
{
#ifndef BOOST_NO_EXCEPTIONS
throw system_error(error_code(int(::ERR_get_error())
, boost::asio::error::get_ssl_category()));
throw system_error(errors::no_entropy);
#else
std::terminate();
#endif