diff options
author | Bram Moolenaar <Bram@vim.org> | 2021-06-27 14:08:24 +0200 |
---|---|---|
committer | Bram Moolenaar <Bram@vim.org> | 2021-06-27 14:08:24 +0200 |
commit | 65aee0b714e809b9f19862f3decd35055ed4de10 (patch) | |
tree | 9aaa368563c0481d5a14e29689cc856370e2fba9 /src/bufwrite.c | |
parent | 4cd5c52d64a66ad1984d33462a40e0c6721ca232 (diff) | |
download | vim-git-65aee0b714e809b9f19862f3decd35055ed4de10.tar.gz |
patch 8.2.3063: crash when switching 'cryptmethod' to xchaha20 with undo filev8.2.3063
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)
Diffstat (limited to 'src/bufwrite.c')
-rw-r--r-- | src/bufwrite.c | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/src/bufwrite.c b/src/bufwrite.c index c91bcd995..e480e57e7 100644 --- a/src/bufwrite.c +++ b/src/bufwrite.c @@ -494,14 +494,16 @@ buf_write_bytes(struct bw_info *ip) if (crypt_works_inplace(ip->bw_buffer->b_cryptstate)) { # endif - crypt_encode_inplace(ip->bw_buffer->b_cryptstate, buf, len, ip->bw_finish); + crypt_encode_inplace(ip->bw_buffer->b_cryptstate, buf, len, + ip->bw_finish); # ifdef CRYPT_NOT_INPLACE } else { char_u *outbuf; - len = crypt_encode_alloc(curbuf->b_cryptstate, buf, len, &outbuf, ip->bw_finish); + len = crypt_encode_alloc(curbuf->b_cryptstate, buf, len, &outbuf, + ip->bw_finish); if (len == 0) return OK; // Crypt layer is buffering, will flush later. wlen = write_eintr(ip->bw_fd, outbuf, len); @@ -1980,10 +1982,18 @@ restore_backup: write_info.bw_start_lnum = start; #ifdef FEAT_PERSISTENT_UNDO + // TODO: if the selected crypt method prevents the undo file from being + // written, and existing undo file should be deleted. write_undo_file = (buf->b_p_udf && overwriting && !append && !filtering +# ifdef CRYPT_NOT_INPLACE + // writing undo file requires + // crypt_encode_inplace() + && (curbuf->b_cryptstate == NULL + || crypt_works_inplace(curbuf->b_cryptstate)) +# endif && reset_changed && !checking_conversion); if (write_undo_file) |