Patch 9.0.1484
Problem:    Coverity warns for using invalid array index.
Solution:   Add entry for Xchacha, even though it is not used.
Files:      src/memline.c


*** ../vim-9.0.1483/src/memline.c       2023-04-23 17:50:14.853935966 +0100
--- src/memline.c       2023-04-24 18:09:04.776300439 +0100
***************
*** 64,70 ****
  #define BLOCK0_ID1_C0  'c'                // block 0 id 1 'cm' 0
  #define BLOCK0_ID1_C1  'C'                // block 0 id 1 'cm' 1
  #define BLOCK0_ID1_C2  'd'                // block 0 id 1 'cm' 2
! #define BLOCK0_ID1_C3  'S'                // block 0 id 1 'cm' 3 - but not 
actually used
  
  #if defined(FEAT_CRYPT)
  static int id1_codes[] = {
--- 64,74 ----
  #define BLOCK0_ID1_C0  'c'                // block 0 id 1 'cm' 0
  #define BLOCK0_ID1_C1  'C'                // block 0 id 1 'cm' 1
  #define BLOCK0_ID1_C2  'd'                // block 0 id 1 'cm' 2
! // BLOCK0_ID1_C3 and BLOCK0_ID1_C4 are for libsodium enctyption.  However, for
! // these the swapfile is disabled, thus they will not be used.  Added for
! // consistency anyway.
! #define BLOCK0_ID1_C3  'S'                // block 0 id 1 'cm' 3
! #define BLOCK0_ID1_C4  's'                // block 0 id 1 'cm' 4
  
  #if defined(FEAT_CRYPT)
  static int id1_codes[] = {
***************
*** 72,77 ****
--- 76,82 ----
      BLOCK0_ID1_C1,  // CRYPT_M_BF
      BLOCK0_ID1_C2,  // CRYPT_M_BF2
      BLOCK0_ID1_C3,  // CRYPT_M_SOD  - Unused!
+     BLOCK0_ID1_C4,  // CRYPT_M_SOD2  - Unused!
  };
  #endif
  
***************
*** 444,449 ****
--- 449,456 ----
  
  /*
   * Prepare encryption for "buf" with block 0 "b0p".
+  * Note: should not be called with libsodium encryption, since xchacha20 does
+  * not support swapfile encryption.
   */
      static void
  ml_set_b0_crypt(buf_T *buf, ZERO_BL *b0p)
***************
*** 494,507 ****
        return;  // no memfile yet, nothing to do
      old_method = crypt_method_nr_from_name(old_cm);
  
!     // Swapfile encryption not supported by XChaCha20
!     if (crypt_method_is_sodium(crypt_get_method_nr(buf)) && *buf->b_p_key != 
NUL)
      {
        // close the swapfile
        mf_close_file(buf, TRUE);
        buf->b_p_swf = FALSE;
        return;
      }
      // First make sure the swapfile is in a consistent state, using the old
      // key and method.
      {
--- 501,517 ----
        return;  // no memfile yet, nothing to do
      old_method = crypt_method_nr_from_name(old_cm);
  
!     // Swapfile encryption is not supported by XChaCha20, therefore disable 
the
!     // swapfile to avoid plain text being written to disk.
!     if (crypt_method_is_sodium(crypt_get_method_nr(buf))
!                                                      && *buf->b_p_key != NUL)
      {
        // close the swapfile
        mf_close_file(buf, TRUE);
        buf->b_p_swf = FALSE;
        return;
      }
+ 
      // First make sure the swapfile is in a consistent state, using the old
      // key and method.
      {
*** ../vim-9.0.1483/src/version.c       2023-04-24 17:15:20.371257120 +0100
--- src/version.c       2023-04-24 18:05:33.124364494 +0100
***************
*** 697,698 ****
--- 697,700 ----
  {   /* Add new patch number below this line */
+ /**/
+     1484,
  /**/

-- 
We apologise again for the fault in the subtitles.  Those responsible for
sacking the people who have just been sacked have been sacked.
                 "Monty Python and the Holy Grail" PYTHON (MONTY) PICTURES LTD

 /// Bram Moolenaar -- [email protected] -- http://www.Moolenaar.net   \\\
///                                                                      \\\
\\\        sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ ///
 \\\            help me help AIDS victims -- http://ICCF-Holland.org    ///

-- 
-- 
You received this message from the "vim_dev" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

--- 
You received this message because you are subscribed to the Google Groups 
"vim_dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/vim_dev/20230424171203.98A4A1C0787%40moolenaar.net.

Raspunde prin e-mail lui