From a8ffcbbf5d6070380e41b3d0841c3944396a27c0 Mon Sep 17 00:00:00 2001 From: Bram Moolenaar Date: Mon, 21 Jun 2010 06:15:46 +0200 Subject: Crypt the swapfile. --- src/option.c | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) (limited to 'src/option.c') diff --git a/src/option.c b/src/option.c index d06381cb8..face9fde9 100644 --- a/src/option.c +++ b/src/option.c @@ -5969,13 +5969,18 @@ did_set_string_option(opt_idx, varp, new_value_alloced, oldval, errbuf, } } -#if defined(FEAT_CRYPT) && defined(FEAT_CMDHIST) +#if defined(FEAT_CRYPT) /* 'cryptkey' */ else if (gvarp == &p_key) { +# if defined(FEAT_CMDHIST) /* Make sure the ":set" command doesn't show the new value in the * history. */ remove_key_from_history(); +# endif + if (STRCMP(curbuf->b_p_key, oldval) != 0) + /* Need to update the swapfile. */ + ml_set_crypt_key(curbuf, oldval, curbuf->b_p_cm); } #endif @@ -7941,15 +7946,19 @@ set_num_option(opt_idx, varp, value, errbuf, errbuflen, opt_flags) if (curbuf->b_p_cm < 0) { errmsg = e_positive; - curbuf->b_p_cm = 0; + curbuf->b_p_cm = old_value; } if (curbuf->b_p_cm > 1) { errmsg = e_invarg; - curbuf->b_p_cm = 1; + curbuf->b_p_cm = old_value; } if (curbuf->b_p_cm > 0 && blowfish_self_test() == FAIL) - curbuf->b_p_cm = 0; + curbuf->b_p_cm = old_value; + + if (curbuf->b_p_cm != old_value && *curbuf->b_p_key != NUL) + /* Need to update the swapfile. */ + ml_set_crypt_key(curbuf, curbuf->b_p_key, old_value); } #endif -- cgit v1.2.1