]> git.ipfire.org Git - thirdparty/vim.git/commitdiff
patch 9.0.1638: crypt tests hang and cause memory errors 12556/head v9.0.1638
authorBram Moolenaar <Bram@vim.org>
Sat, 17 Jun 2023 14:00:27 +0000 (15:00 +0100)
committerBram Moolenaar <Bram@vim.org>
Sat, 17 Jun 2023 14:00:27 +0000 (15:00 +0100)
Problem:    crypt tests hang and cause memory errors
Solution:   Move variable to start of function.

src/fileio.c
src/version.c

index 4f3b895f2bf4ecf6e6a4815be7a18b859d4ccc11..8b65baf62a5a101ea6f85d3dec00414e531cfb89 100644 (file)
@@ -218,6 +218,7 @@ readfile(
     int                using_b_ffname;
     int                using_b_fname;
     static char *msg_is_a_directory = N_("is a directory");
+    int                eof = FALSE;
 #ifdef FEAT_SODIUM
     int                may_need_lseek = FALSE;
 #endif
@@ -1222,7 +1223,6 @@ retry:
                    size -= conv_restlen;
                }
 
-               int eof = FALSE;
                if (read_buffer)
                {
                    /*
@@ -1306,8 +1306,8 @@ retry:
                    {
                        // set size to 8K + Sodium Crypt Metadata
                        size = WRITEBUFSIZE + crypt_get_max_header_len()
-                    + crypto_secretstream_xchacha20poly1305_HEADERBYTES
-                    + crypto_secretstream_xchacha20poly1305_ABYTES;
+                           + crypto_secretstream_xchacha20poly1305_HEADERBYTES
+                               + crypto_secretstream_xchacha20poly1305_ABYTES;
                        may_need_lseek = TRUE;
                    }
 
@@ -1328,11 +1328,11 @@ retry:
                        }
                    }
 # endif
-                   eof = size;
-                   size = read_eintr(fd, ptr, size);
+                   long read_size = size;
+                   size = read_eintr(fd, ptr, read_size);
                    filesize_count += size;
                    // hit end of file
-                   eof = (size < eof || filesize_count == filesize_disk);
+                   eof = (size < read_size || filesize_count == filesize_disk);
                }
 
 #ifdef FEAT_CRYPT
index a91e6fb0e7d00c6233400a3827cb87496efdfb2c..9488cdac01f00be45677ae4199f7597282defdbd 100644 (file)
@@ -695,6 +695,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    1638,
 /**/
     1637,
 /**/