From 778fa529f4c854fd4f50cec9401316954a0591bf Mon Sep 17 00:00:00 2001 From: Andrei Lebedev Date: Tue, 10 Jul 2018 16:10:12 +0300 Subject: [PATCH] Add missing close() calls for files Signed-off-by: Andrei Lebedev --- lib/randombytes/random/random.c | 1 + lib/randombytes/urandom/urandom.c | 3 +++ 2 files changed, 4 insertions(+) diff --git a/lib/randombytes/random/random.c b/lib/randombytes/random/random.c index e5eca79..e6e862e 100644 --- a/lib/randombytes/random/random.c +++ b/lib/randombytes/random/random.c @@ -13,6 +13,7 @@ int randombytes(unsigned char *p, int len) { while (completed < len) { ssize_t result = read(source, p + completed, len - completed); if (result < 0) { + close(source); return ED25519_ERROR; } completed += result; diff --git a/lib/randombytes/urandom/urandom.c b/lib/randombytes/urandom/urandom.c index ecad2cf..5b4ec0d 100644 --- a/lib/randombytes/urandom/urandom.c +++ b/lib/randombytes/urandom/urandom.c @@ -9,9 +9,12 @@ int randombytes(unsigned char *p, int len) { } else { ssize_t result = read(source, p, len); if (result < 0) { + close(source); return ED25519_ERROR; /* something went wrong */ } } + close(source); + return ED25519_SUCCESS; }