home *** CD-ROM | disk | FTP | other *** search
/ vim.ftp.fu-berlin.de / 2015-02-03.vim.ftp.fu-berlin.de.tar / vim.ftp.fu-berlin.de / patches / 7.4 / 7.4.403 < prev    next >
Encoding:
Internet Message Format  |  2014-08-13  |  4.0 KB

  1. To: vim_dev@googlegroups.com
  2. Subject: Patch 7.4.403
  3. Fcc: outbox
  4. From: Bram Moolenaar <Bram@moolenaar.net>
  5. Mime-Version: 1.0
  6. Content-Type: text/plain; charset=UTF-8
  7. Content-Transfer-Encoding: 8bit
  8. ------------
  9.  
  10. Patch 7.4.403
  11. Problem:    Valgrind reports errors when running test 72. (Dominique Pelle)
  12. Solution:   Reset the local 'cryptmethod' option before storing the seed.
  13.         Set the seed in the memfile even when there is no block0 yet.
  14. Files:        src/fileio.c, src/option.c, src/memline.c
  15.  
  16.  
  17. *** ../vim-7.4.402/src/fileio.c    2014-08-10 13:34:59.056785459 +0200
  18. --- src/fileio.c    2014-08-13 21:27:51.452857400 +0200
  19. ***************
  20. *** 2944,2949 ****
  21. --- 2944,2950 ----
  22.        * Avoids accidentally overwriting the file with garbage. */
  23.       curbuf->b_p_ro = TRUE;
  24.   
  25. +     /* Set the cryptmethod local to the buffer. */
  26.       crypt_set_cm_option(curbuf, method);
  27.       if (cryptkey == NULL && !*did_ask)
  28.       {
  29. *** ../vim-7.4.402/src/option.c    2014-08-10 13:34:59.060785459 +0200
  30. --- src/option.c    2014-08-13 21:48:49.924876683 +0200
  31. ***************
  32. *** 6163,6168 ****
  33. --- 6163,6176 ----
  34.           p_cm = vim_strsave((char_u *)"zip");
  35.           new_value_alloced = TRUE;
  36.           }
  37. +         /* When using ":set cm=name" the local value is going to be empty.
  38. +          * Do that here, otherwise the crypt functions will still use the
  39. +          * local value. */
  40. +         if ((opt_flags & (OPT_LOCAL | OPT_GLOBAL)) == 0)
  41. +         {
  42. +         free_string_option(curbuf->b_p_cm);
  43. +         curbuf->b_p_cm = empty_option;
  44. +         }
  45.   
  46.           /* Need to update the swapfile when the effective method changed.
  47.            * Set "s" to the effective old value, "p" to the effective new
  48. *** ../vim-7.4.402/src/memline.c    2014-08-10 13:34:59.060785459 +0200
  49. --- src/memline.c    2014-08-13 21:52:40.076880210 +0200
  50. ***************
  51. *** 235,240 ****
  52. --- 235,241 ----
  53.   } upd_block0_T;
  54.   
  55.   #ifdef FEAT_CRYPT
  56. + static void ml_set_mfp_crypt __ARGS((buf_T *buf));
  57.   static void ml_set_b0_crypt __ARGS((buf_T *buf, ZERO_BL *b0p));
  58.   #endif
  59.   static int ml_check_b0_id __ARGS((ZERO_BL *b0p));
  60. ***************
  61. *** 433,438 ****
  62. --- 434,458 ----
  63.   
  64.   #if defined(FEAT_CRYPT) || defined(PROTO)
  65.   /*
  66. +  * Prepare encryption for "buf" for the current key and method.
  67. +  */
  68. +     static void
  69. + ml_set_mfp_crypt(buf)
  70. +     buf_T    *buf;
  71. + {
  72. +     if (*buf->b_p_key != NUL)
  73. +     {
  74. +     int method_nr = crypt_get_method_nr(buf);
  75. +     if (method_nr > CRYPT_M_ZIP)
  76. +     {
  77. +         /* Generate a seed and store it in the memfile. */
  78. +         sha2_seed(buf->b_ml.ml_mfp->mf_seed, MF_SEED_LEN, NULL, 0);
  79. +     }
  80. +     }
  81. + }
  82. + /*
  83.    * Prepare encryption for "buf" with block 0 "b0p".
  84.    */
  85.       static void
  86. ***************
  87. *** 915,922 ****
  88.       ZERO_BL    *b0p;
  89.   
  90.       mfp = buf->b_ml.ml_mfp;
  91. !     if (mfp == NULL || (hp = mf_get(mfp, (blocknr_T)0, 1)) == NULL)
  92.       return;
  93.       b0p = (ZERO_BL *)(hp->bh_data);
  94.       if (ml_check_b0_id(b0p) == FAIL)
  95.       EMSG(_("E304: ml_upd_block0(): Didn't get block 0??"));
  96. --- 935,953 ----
  97.       ZERO_BL    *b0p;
  98.   
  99.       mfp = buf->b_ml.ml_mfp;
  100. !     if (mfp == NULL)
  101. !     return;
  102. !     hp = mf_get(mfp, (blocknr_T)0, 1);
  103. !     if (hp == NULL)
  104. !     {
  105. ! #ifdef FEAT_CRYPT
  106. !     /* Possibly update the seed in the memfile before there is a block0. */
  107. !     if (what == UB_CRYPT)
  108. !         ml_set_mfp_crypt(buf);
  109. ! #endif
  110.       return;
  111. +     }
  112.       b0p = (ZERO_BL *)(hp->bh_data);
  113.       if (ml_check_b0_id(b0p) == FAIL)
  114.       EMSG(_("E304: ml_upd_block0(): Didn't get block 0??"));
  115. *** ../vim-7.4.402/src/version.c    2014-08-12 20:14:28.795371197 +0200
  116. --- src/version.c    2014-08-13 17:23:02.964632329 +0200
  117. ***************
  118. *** 743,744 ****
  119. --- 743,746 ----
  120.   {   /* Add new patch number below this line */
  121. + /**/
  122. +     403,
  123.   /**/
  124.  
  125. -- 
  126. How To Keep A Healthy Level Of Insanity:
  127. 9. As often as possible, skip rather than walk.
  128.  
  129.  /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net   \\\
  130. ///        sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
  131. \\\  an exciting new programming language -- http://www.Zimbu.org        ///
  132.  \\\            help me help AIDS victims -- http://ICCF-Holland.org    ///
  133.