diff options
author | Wladimir J. van der Laan <laanwj@gmail.com> | 2017-07-17 13:10:50 +0200 |
---|---|---|
committer | Wladimir J. van der Laan <laanwj@gmail.com> | 2017-07-17 13:14:09 +0200 |
commit | 8bc6d1f179a0f51f86b78b9b394b4ba5c2543e93 (patch) | |
tree | fcff12cb44d0625601be8e26b84a5ac411c2dfb6 /src | |
parent | 91edda8f3c81ba5a69f44485f20d74f85ec9cee1 (diff) | |
parent | a8ae0b252a2007568e77f5aca1c7fa3ec5941b72 (diff) |
Merge #10837: Fix resource leak on error in GetDevURandom
a8ae0b2 Fix resource leak (Dag Robole)
Pull request description:
Fixes a potential file handle leak when size of entropy is invalid
Tree-SHA512: 692d24daaf370bba1f842925b037275126f9494f54769650bcf5829c794a0fb8561a86f42347bdf088a484e4f107bce7fa14cd7bdbfb4ecfbeb51968953da3ae
Diffstat (limited to 'src')
-rw-r--r-- | src/random.cpp | 1 |
1 files changed, 1 insertions, 0 deletions
diff --git a/src/random.cpp b/src/random.cpp index 1ee6158e4b..3226abb69e 100644 --- a/src/random.cpp +++ b/src/random.cpp @@ -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; |