diff src/fileio.c @ 25052:965d97f8208b v8.2.3063

patch 8.2.3063: crash when switching 'cryptmethod' to xchaha20 with undo file Commit: https://github.com/vim/vim/commit/65aee0b714e809b9f19862f3decd35055ed4de10 Author: Bram Moolenaar <Bram@vim.org> Date: Sun Jun 27 14:08:24 2021 +0200 patch 8.2.3063: crash when switching 'cryptmethod' to xchaha20 with undo file Problem: Crash when switching 'cryptmethod' to xchaha20 with an existing undo file. (Martin Tournoij) Solution: Disable reading undo file when decoding can't be done inplace. (issue #8467)
author Bram Moolenaar <Bram@vim.org>
date Sun, 27 Jun 2021 14:15:03 +0200
parents 85d1e82ed134
children 0ce24f734615
line wrap: on
line diff
--- a/src/fileio.c
+++ b/src/fileio.c
@@ -1298,9 +1298,17 @@ retry:
 		 * At start of file: Check for magic number of encryption.
 		 */
 		if (filesize == 0 && size > 0)
+		{
 		    cryptkey = check_for_cryptkey(cryptkey, ptr, &size,
 						  &filesize, newfile, sfname,
 						  &did_ask_for_key);
+# ifdef CRYPT_NOT_INPLACE
+		    if (curbuf->b_cryptstate != NULL
+				 && !crypt_works_inplace(curbuf->b_cryptstate))
+			// reading undo file requires crypt_decode_inplace()
+			read_undo_file = FALSE;
+# endif
+		}
 		/*
 		 * Decrypt the read bytes.  This is done before checking for
 		 * EOF because the crypt layer may be buffering.