Blame SOURCES/7.4.509

22c937
To: vim_dev@googlegroups.com
22c937
Subject: Patch 7.4.509
22c937
Fcc: outbox
22c937
From: Bram Moolenaar <Bram@moolenaar.net>
22c937
Mime-Version: 1.0
22c937
Content-Type: text/plain; charset=UTF-8
22c937
Content-Transfer-Encoding: 8bit
22c937
------------
22c937
22c937
Patch 7.4.509
22c937
Problem:    Users are not aware their encryption is weak.
22c937
Solution:   Give a warning when prompting for the key.
22c937
Files:	    src/crypt.c, src/ex_docmd.c, src/fileio.c, src/main.c,
22c937
	    src/proto/crypt.pro
22c937
22c937
22c937
*** ../vim-7.4.508/src/crypt.c	2014-08-13 22:05:49.032892299 +0200
22c937
--- src/crypt.c	2014-11-12 15:10:22.359161977 +0100
22c937
***************
22c937
*** 504,509 ****
22c937
--- 504,529 ----
22c937
  }
22c937
  
22c937
  /*
22c937
+  * Check the crypt method and give a warning if it's outdated.
22c937
+  */
22c937
+     void
22c937
+ crypt_check_method(method)
22c937
+     int method;
22c937
+ {
22c937
+     if (method < CRYPT_M_BF2)
22c937
+     {
22c937
+ 	msg_scroll = TRUE;
22c937
+ 	MSG(_("Warning: Using a weak encryption method; see :help 'cm'"));
22c937
+     }
22c937
+ }
22c937
+ 
22c937
+     void
22c937
+ crypt_check_current_method()
22c937
+ {
22c937
+     crypt_check_method(crypt_get_method_nr(curbuf));
22c937
+ }
22c937
+ 
22c937
+ /*
22c937
   * Ask the user for a crypt key.
22c937
   * When "store" is TRUE, the new key is stored in the 'key' option, and the
22c937
   * 'key' option value is returned: Don't free it.
22c937
*** ../vim-7.4.508/src/ex_docmd.c	2014-11-05 09:53:19.989153321 +0100
22c937
--- src/ex_docmd.c	2014-11-12 14:53:09.621921631 +0100
22c937
***************
22c937
*** 11524,11529 ****
22c937
--- 11524,11530 ----
22c937
  ex_X(eap)
22c937
      exarg_T	*eap UNUSED;
22c937
  {
22c937
+     crypt_check_current_method();
22c937
      (void)crypt_get_key(TRUE, TRUE);
22c937
  }
22c937
  #endif
22c937
*** ../vim-7.4.508/src/fileio.c	2014-10-31 19:51:33.010698056 +0100
22c937
--- src/fileio.c	2014-11-12 15:10:44.986925300 +0100
22c937
***************
22c937
*** 2958,2963 ****
22c937
--- 2958,2964 ----
22c937
  		 * Happens when retrying to detect encoding. */
22c937
  		smsg((char_u *)_(need_key_msg), fname);
22c937
  		msg_scroll = TRUE;
22c937
+ 		crypt_check_method(method);
22c937
  		cryptkey = crypt_get_key(newfile, FALSE);
22c937
  		*did_ask = TRUE;
22c937
  
22c937
*** ../vim-7.4.508/src/main.c	2014-09-19 13:46:49.550399801 +0200
22c937
--- src/main.c	2014-11-12 14:52:47.866169622 +0100
22c937
***************
22c937
*** 854,859 ****
22c937
--- 854,860 ----
22c937
  #ifdef FEAT_CRYPT
22c937
      if (params.ask_for_key)
22c937
      {
22c937
+ 	crypt_check_current_method();
22c937
  	(void)crypt_get_key(TRUE, TRUE);
22c937
  	TIME_MSG("getting crypt key");
22c937
      }
22c937
*** ../vim-7.4.508/src/proto/crypt.pro	2014-08-10 13:34:59.060785459 +0200
22c937
--- src/proto/crypt.pro	2014-11-12 15:06:51.349363319 +0100
22c937
***************
22c937
*** 19,24 ****
22c937
--- 19,26 ----
22c937
  void crypt_encode_inplace __ARGS((cryptstate_T *state, char_u *buf, size_t len));
22c937
  void crypt_decode_inplace __ARGS((cryptstate_T *state, char_u *buf, size_t len));
22c937
  void crypt_free_key __ARGS((char_u *key));
22c937
+ void crypt_check_method __ARGS((int method));
22c937
+ void crypt_check_current_method __ARGS((void));
22c937
  char_u *crypt_get_key __ARGS((int store, int twice));
22c937
  void crypt_append_msg __ARGS((buf_T *buf));
22c937
  /* vim: set ft=c : */
22c937
*** ../vim-7.4.508/src/version.c	2014-11-12 13:07:48.774069557 +0100
22c937
--- src/version.c	2014-11-12 14:45:09.979391243 +0100
22c937
***************
22c937
*** 743,744 ****
22c937
--- 743,746 ----
22c937
  {   /* Add new patch number below this line */
22c937
+ /**/
22c937
+     509,
22c937
  /**/
22c937
22c937
-- 
22c937
Q: How do you tell the difference between a female cat and a male cat?
22c937
A: You ask it a question and if HE answers, it's a male but, if SHE
22c937
   answers, it's a female.
22c937
22c937
 /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net   \\\
22c937
///        sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
22c937
\\\  an exciting new programming language -- http://www.Zimbu.org        ///
22c937
 \\\            help me help AIDS victims -- http://ICCF-Holland.org    ///