patch 7.4.730
Problem: When setting the crypt key and using a swap file, text may be
encrypted twice or unencrypted text remains in the swap file.
(Issue 369)
Solution: Call ml_preserve() before re-encrypting. Set correct index for
next pointer block.
diff --git a/src/option.c b/src/option.c
index 56d9493..7bcb26a 100644
--- a/src/option.c
+++ b/src/option.c
@@ -6163,7 +6163,8 @@
# endif
if (STRCMP(curbuf->b_p_key, oldval) != 0)
/* Need to update the swapfile. */
- ml_set_crypt_key(curbuf, oldval, crypt_get_method_nr(curbuf));
+ ml_set_crypt_key(curbuf, oldval,
+ *curbuf->b_p_cm == NUL ? p_cm : curbuf->b_p_cm);
}
else if (gvarp == &p_cm)
@@ -6207,8 +6208,7 @@
else
p = curbuf->b_p_cm;
if (STRCMP(s, p) != 0)
- ml_set_crypt_key(curbuf, curbuf->b_p_key,
- crypt_method_nr_from_name(s));
+ ml_set_crypt_key(curbuf, curbuf->b_p_key, s);
/* If the global value changes need to update the swapfile for all
* buffers using that value. */
@@ -6218,8 +6218,7 @@
for (buf = firstbuf; buf != NULL; buf = buf->b_next)
if (buf != curbuf && *buf->b_p_cm == NUL)
- ml_set_crypt_key(buf, buf->b_p_key,
- crypt_method_nr_from_name(oldval));
+ ml_set_crypt_key(buf, buf->b_p_key, oldval);
}
}
}