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
This commit is contained in:
Wladimir J. van der Laan 2017-07-17 13:10:50 +02:00 committed by Pasta
parent 9ad533089d
commit 083c49e1d2
No known key found for this signature in database
GPG Key ID: D362C9F7142766AE

View File

@ -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;