Skip to content

Commit 8bc6d1f

Browse files
committed
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
2 parents 91edda8 + a8ae0b2 commit 8bc6d1f

File tree

1 file changed

+1
-0
lines changed

1 file changed

+1
-0
lines changed

src/random.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -186,6 +186,7 @@ void GetDevURandom(unsigned char *ent32)
186186
do {
187187
ssize_t n = read(f, ent32 + have, NUM_OS_RANDOM_BYTES - have);
188188
if (n <= 0 || n + have > NUM_OS_RANDOM_BYTES) {
189+
close(f);
189190
RandFailure();
190191
}
191192
have += n;

0 commit comments

Comments
 (0)