diff options
author | Bram Moolenaar <Bram@vim.org> | 2014-08-13 21:58:28 +0200 |
---|---|---|
committer | Bram Moolenaar <Bram@vim.org> | 2014-08-13 21:58:28 +0200 |
commit | 2be795084f053928879d758443e199ef147cc07e (patch) | |
tree | f463c710036022d066b5d852bcd1dac1140d2dab /src/memline.c | |
parent | 5a669b94814a5ca1ff69f76f18c75a90f4404ca6 (diff) | |
download | vim-git-2be795084f053928879d758443e199ef147cc07e.tar.gz |
updated for version 7.4.403v7.4.403
Problem: Valgrind reports errors when running test 72. (Dominique Pelle)
Solution: Reset the local 'cryptmethod' option before storing the seed.
Set the seed in the memfile even when there is no block0 yet.
Diffstat (limited to 'src/memline.c')
-rw-r--r-- | src/memline.c | 33 |
1 files changed, 32 insertions, 1 deletions
diff --git a/src/memline.c b/src/memline.c index a5053f023..7adb2dc99 100644 --- a/src/memline.c +++ b/src/memline.c @@ -235,6 +235,7 @@ typedef enum { } upd_block0_T; #ifdef FEAT_CRYPT +static void ml_set_mfp_crypt __ARGS((buf_T *buf)); static void ml_set_b0_crypt __ARGS((buf_T *buf, ZERO_BL *b0p)); #endif static int ml_check_b0_id __ARGS((ZERO_BL *b0p)); @@ -433,6 +434,25 @@ error: #if defined(FEAT_CRYPT) || defined(PROTO) /* + * Prepare encryption for "buf" for the current key and method. + */ + static void +ml_set_mfp_crypt(buf) + buf_T *buf; +{ + if (*buf->b_p_key != NUL) + { + int method_nr = crypt_get_method_nr(buf); + + if (method_nr > CRYPT_M_ZIP) + { + /* Generate a seed and store it in the memfile. */ + sha2_seed(buf->b_ml.ml_mfp->mf_seed, MF_SEED_LEN, NULL, 0); + } + } +} + +/* * Prepare encryption for "buf" with block 0 "b0p". */ static void @@ -915,8 +935,19 @@ ml_upd_block0(buf, what) ZERO_BL *b0p; mfp = buf->b_ml.ml_mfp; - if (mfp == NULL || (hp = mf_get(mfp, (blocknr_T)0, 1)) == NULL) + if (mfp == NULL) return; + hp = mf_get(mfp, (blocknr_T)0, 1); + if (hp == NULL) + { +#ifdef FEAT_CRYPT + /* Possibly update the seed in the memfile before there is a block0. */ + if (what == UB_CRYPT) + ml_set_mfp_crypt(buf); +#endif + return; + } + b0p = (ZERO_BL *)(hp->bh_data); if (ml_check_b0_id(b0p) == FAIL) EMSG(_("E304: ml_upd_block0(): Didn't get block 0??")); |