Skip to content

Commit

Permalink
Merge bitcoin#10837: Fix resource leak on error in GetDevURandom
Browse files Browse the repository at this point in the history
a8ae0b2 Fix resource leak (Dag Robole)

Pull request description:

  Fixes a potential file handle leak when size of entropy is invalid

Tree-SHA512: 692d24daaf370bba1f842925b037275126f9494f54769650bcf5829c794a0fb8561a86f42347bdf088a484e4f107bce7fa14cd7bdbfb4ecfbeb51968953da3ae
  • Loading branch information
laanwj committed Jul 17, 2017
2 parents 91edda8 + a8ae0b2 commit 8bc6d1f
Showing 1 changed file with 1 addition and 0 deletions.
1 change: 1 addition & 0 deletions src/random.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,7 @@ void GetDevURandom(unsigned char *ent32)
do {
ssize_t n = read(f, ent32 + have, NUM_OS_RANDOM_BYTES - have);
if (n <= 0 || n + have > NUM_OS_RANDOM_BYTES) {
close(f);
RandFailure();
}
have += n;
Expand Down

0 comments on commit 8bc6d1f

Please sign in to comment.