Skip to content

Commit

Permalink
Merge pull request aria2#823 from aria2/fix-getrandom-assertion-failure
Browse files Browse the repository at this point in the history
Fix assertion failure in SimpleRandomizer::getRandomBytes
  • Loading branch information
tatsuhiro-t authored Jan 7, 2017
2 parents 5d2742d + e2dc090 commit 6abf238
Showing 1 changed file with 1 addition and 12 deletions.
13 changes: 1 addition & 12 deletions src/SimpleRandomizer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -101,18 +101,7 @@ void SimpleRandomizer::getRandomBytes(unsigned char* buf, size_t len)
static bool have_random_support = true;
if (have_random_support) {
auto rv = getrandom_linux(buf, len);
if (rv != -1
#ifdef ENOSYS
/* If the system does not know ENOSYS at this point, just leave the
* check out. If the call failed, we'll not take this branch at all
* and disable support below.
*/
|| errno != ENOSYS
#endif
) {
if (rv < -1) {
A2_LOG_ERROR(fmt("Failed to produce randomness: %d", errno));
}
if (rv != -1) {
// getrandom is not supposed to fail, ever, so, we want to assert here.
assert(rv >= 0 && (size_t)rv == len);
return;
Expand Down

0 comments on commit 6abf238

Please sign in to comment.