Mercurial > vim
comparison 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 |
comparison
equal
deleted
inserted
replaced
25051:bffb0c617c1c | 25052:965d97f8208b |
---|---|
1296 #ifdef FEAT_CRYPT | 1296 #ifdef FEAT_CRYPT |
1297 /* | 1297 /* |
1298 * At start of file: Check for magic number of encryption. | 1298 * At start of file: Check for magic number of encryption. |
1299 */ | 1299 */ |
1300 if (filesize == 0 && size > 0) | 1300 if (filesize == 0 && size > 0) |
1301 { | |
1301 cryptkey = check_for_cryptkey(cryptkey, ptr, &size, | 1302 cryptkey = check_for_cryptkey(cryptkey, ptr, &size, |
1302 &filesize, newfile, sfname, | 1303 &filesize, newfile, sfname, |
1303 &did_ask_for_key); | 1304 &did_ask_for_key); |
1305 # ifdef CRYPT_NOT_INPLACE | |
1306 if (curbuf->b_cryptstate != NULL | |
1307 && !crypt_works_inplace(curbuf->b_cryptstate)) | |
1308 // reading undo file requires crypt_decode_inplace() | |
1309 read_undo_file = FALSE; | |
1310 # endif | |
1311 } | |
1304 /* | 1312 /* |
1305 * Decrypt the read bytes. This is done before checking for | 1313 * Decrypt the read bytes. This is done before checking for |
1306 * EOF because the crypt layer may be buffering. | 1314 * EOF because the crypt layer may be buffering. |
1307 */ | 1315 */ |
1308 if (cryptkey != NULL && curbuf->b_cryptstate != NULL | 1316 if (cryptkey != NULL && curbuf->b_cryptstate != NULL |