From 4e7eda5c5df043aa79effa89925fcd4a5abf9be2 Mon Sep 17 00:00:00 2001 From: "Matthias P. Braendli" Date: Mon, 18 Nov 2019 10:53:13 +0100 Subject: Fix leak of fd in readkey --- src/encryption.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/encryption.c b/src/encryption.c index f39fd28..c980e4c 100644 --- a/src/encryption.c +++ b/src/encryption.c @@ -29,8 +29,10 @@ int readkey(const char* keyfile, char* key) if (fd < 0) return fd; int ret = read(fd, key, CURVE_KEYLEN); - if (ret < 0) + if (ret < 0) { + close(fd); return ret; + } close(fd); /* It needs to be zero-terminated */ -- cgit v1.2.3