Patch 8.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)
Files: src/fileio.c, src/bufwrite.c
*** ../vim-8.2.3062/src/fileio.c 2021-06-21 21:08:04.928547486 +0200
--- src/fileio.c 2021-06-27 14:06:41.056331092 +0200
***************
*** 1298,1306 ****
--- 1298,1314 ----
* 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.
*** ../vim-8.2.3062/src/bufwrite.c 2021-06-20 14:01:25.980924619 +0200
--- src/bufwrite.c 2021-06-27 14:06:08.216406574 +0200
***************
*** 494,507 ****
if (crypt_works_inplace(ip->bw_buffer->b_cryptstate))
{
# endif
! 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);
if (len == 0)
return OK; // Crypt layer is buffering, will flush later.
wlen = write_eintr(ip->bw_fd, outbuf, len);
--- 494,509 ----
if (crypt_works_inplace(ip->bw_buffer->b_cryptstate))
{
# endif
! 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);
if (len == 0)
return OK; // Crypt layer is buffering, will flush later.
wlen = write_eintr(ip->bw_fd, outbuf, len);
***************
*** 1980,1989 ****
--- 1982,1999 ----
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)
*** ../vim-8.2.3062/src/version.c 2021-06-27 13:03:55.990467766 +0200
--- src/version.c 2021-06-27 13:50:58.650647001 +0200
***************
*** 757,758 ****
--- 757,760 ----
{ /* Add new patch number below this line */
+ /**/
+ 3063,
/**/
--
It is hard to understand how a cemetery raised its burial
cost and blamed it on the cost of living.
/// Bram Moolenaar -- Br...@Moolenaar.net --
http://www.Moolenaar.net \\\
/// \\\
\\\ sponsor Vim, vote for features --
http://www.Vim.org/sponsor/ ///
\\\ help me help AIDS victims --
http://ICCF-Holland.org ///