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:
commit
8bc6d1f179
1 changed files with 1 additions and 0 deletions
|
@ -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…
Add table
Reference in a new issue