]> git.ipfire.org Git - thirdparty/vim.git/commitdiff
patch 9.1.0531: resource leak in mch_get_random() v9.1.0531
authorChristian Brabandt <cb@256bit.org>
Fri, 5 Jul 2024 07:54:30 +0000 (09:54 +0200)
committerChristian Brabandt <cb@256bit.org>
Fri, 5 Jul 2024 07:58:58 +0000 (09:58 +0200)
Problem:  resource leak in mch_get_random() (after v9.1.0518)
Solution: close file descriptor after reading successfully
          from /dev/urandom

Signed-off-by: Christian Brabandt <cb@256bit.org>
src/os_unix.c
src/version.c

index b7da55205d61cbf631f93448ef5b5765c426b7d4..474d28801977279b53d33593bcd3bdd233d031be 100644 (file)
@@ -7740,7 +7740,10 @@ mch_get_random(char_u *buf, int len)
     if (fd == -1)
        dev_urandom_state = FAIL;
     else if (read(fd, buf, len) == len)
+    {
        dev_urandom_state = OK;
+       close(fd);
+    }
     else
     {
        dev_urandom_state = FAIL;
index 159fe3b8140353933ea12ebacb00226063b9f05a..9cf60326ae2f23d24f41c3659e080ca343155e97 100644 (file)
@@ -704,6 +704,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    531,
 /**/
     530,
 /**/