mirror of
https://github.com/vim/vim.git
synced 2025-09-26 04:04:07 -04:00
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)
This commit is contained in:
@@ -494,14 +494,16 @@ buf_write_bytes(struct bw_info *ip)
|
|||||||
if (crypt_works_inplace(ip->bw_buffer->b_cryptstate))
|
if (crypt_works_inplace(ip->bw_buffer->b_cryptstate))
|
||||||
{
|
{
|
||||||
# endif
|
# 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
|
# ifdef CRYPT_NOT_INPLACE
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
char_u *outbuf;
|
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)
|
if (len == 0)
|
||||||
return OK; // Crypt layer is buffering, will flush later.
|
return OK; // Crypt layer is buffering, will flush later.
|
||||||
wlen = write_eintr(ip->bw_fd, outbuf, len);
|
wlen = write_eintr(ip->bw_fd, outbuf, len);
|
||||||
@@ -1980,10 +1982,18 @@ restore_backup:
|
|||||||
write_info.bw_start_lnum = start;
|
write_info.bw_start_lnum = start;
|
||||||
|
|
||||||
#ifdef FEAT_PERSISTENT_UNDO
|
#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
|
write_undo_file = (buf->b_p_udf
|
||||||
&& overwriting
|
&& overwriting
|
||||||
&& !append
|
&& !append
|
||||||
&& !filtering
|
&& !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
|
&& reset_changed
|
||||||
&& !checking_conversion);
|
&& !checking_conversion);
|
||||||
if (write_undo_file)
|
if (write_undo_file)
|
||||||
|
@@ -1298,9 +1298,17 @@ retry:
|
|||||||
* At start of file: Check for magic number of encryption.
|
* At start of file: Check for magic number of encryption.
|
||||||
*/
|
*/
|
||||||
if (filesize == 0 && size > 0)
|
if (filesize == 0 && size > 0)
|
||||||
|
{
|
||||||
cryptkey = check_for_cryptkey(cryptkey, ptr, &size,
|
cryptkey = check_for_cryptkey(cryptkey, ptr, &size,
|
||||||
&filesize, newfile, sfname,
|
&filesize, newfile, sfname,
|
||||||
&did_ask_for_key);
|
&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
|
* Decrypt the read bytes. This is done before checking for
|
||||||
* EOF because the crypt layer may be buffering.
|
* EOF because the crypt layer may be buffering.
|
||||||
|
@@ -755,6 +755,8 @@ static char *(features[]) =
|
|||||||
|
|
||||||
static int included_patches[] =
|
static int included_patches[] =
|
||||||
{ /* Add new patch number below this line */
|
{ /* Add new patch number below this line */
|
||||||
|
/**/
|
||||||
|
3063,
|
||||||
/**/
|
/**/
|
||||||
3062,
|
3062,
|
||||||
/**/
|
/**/
|
||||||
|
Reference in New Issue
Block a user