From f9960c026200a7abda9575cb80fb397dbf705d7e Mon Sep 17 00:00:00 2001 From: Jilles Tjoelker Date: Sun, 23 Feb 2014 22:18:44 +0100 Subject: [PATCH] extensions/mkpasswd: Do not leak /dev/random fd. --- extensions/m_mkpasswd.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/extensions/m_mkpasswd.c b/extensions/m_mkpasswd.c index e0cdfe98..80fe64f8 100644 --- a/extensions/m_mkpasswd.c +++ b/extensions/m_mkpasswd.c @@ -210,6 +210,7 @@ generate_random_salt(char *salt, int length) if(read(fd, buf, length) != length) { free(buf); + close(fd); return (generate_poor_salt(salt, length)); } @@ -218,5 +219,6 @@ generate_random_salt(char *salt, int length) salt[i] = saltChars[abs(buf[i]) % 64]; } free(buf); + close(fd); return (salt); }