Browse Source

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
0.15
Wladimir J. van der Laan 8 years ago
parent
commit
8bc6d1f179
No known key found for this signature in database
GPG Key ID: 1E4AED62986CD25D
  1. 1
      src/random.cpp

1
src/random.cpp

@ -186,6 +186,7 @@ void GetDevURandom(unsigned char *ent32) @@ -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;

Loading…
Cancel
Save