summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBram Moolenaar <Bram@vim.org>2023-04-24 18:11:35 +0100
committerBram Moolenaar <Bram@vim.org>2023-04-24 18:11:35 +0100
commite1b4822137b74d45fde1d47d2e32b3ae89966092 (patch)
tree7cd7b67b666cdf951f52cd737ca088392d750524
parent22363c69945e48a7496f0ae00bc06235084ddd7a (diff)
patch 9.0.1484: Coverity warns for using invalid array indexv9.0.1484
Problem: Coverity warns for using invalid array index. Solution: Add entry for Xchacha, even though it is not used.
-rw-r--r--src/memline.c16
-rw-r--r--src/version.c2
2 files changed, 15 insertions, 3 deletions
diff --git a/src/memline.c b/src/memline.c
index 8a3bd16293..527552cff2 100644
--- a/src/memline.c
+++ b/src/memline.c
@@ -64,7 +64,11 @@ typedef struct pointer_entry PTR_EN; // block/line-count pair
#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
+// 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,6 +76,7 @@ static int id1_codes[] = {
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,6 +449,8 @@ ml_set_mfp_crypt(buf_T *buf)
/*
* 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,14 +501,17 @@ ml_set_crypt_key(
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)
+ // 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.
{
diff --git a/src/version.c b/src/version.c
index 842b5830e0..e5099dd473 100644
--- a/src/version.c
+++ b/src/version.c
@@ -696,6 +696,8 @@ static char *(features[]) =
static int included_patches[] =
{ /* Add new patch number below this line */
/**/
+ 1484,
+/**/
1483,
/**/
1482,