Karsten Hopp 25b3f7
To: vim-dev@vim.org
Karsten Hopp 25b3f7
Subject: Patch 7.2.435
Karsten Hopp 25b3f7
Fcc: outbox
Karsten Hopp 25b3f7
From: Bram Moolenaar <Bram@moolenaar.net>
Karsten Hopp 25b3f7
Mime-Version: 1.0
Karsten Hopp 25b3f7
Content-Type: text/plain; charset=UTF-8
Karsten Hopp 25b3f7
Content-Transfer-Encoding: 8bit
Karsten Hopp 25b3f7
------------
Karsten Hopp 25b3f7
Karsten Hopp 25b3f7
Patch 7.2.435 (after 7.2.430)
Karsten Hopp 25b3f7
Problem:    Crash when using bad_char_idx uninitialized. (Patrick Texier)
Karsten Hopp 25b3f7
Solution:   Don't use bad_char_idx, reproduce the ++bad argument from bad_char.
Karsten Hopp 25b3f7
Files:	    src/eval.c, src/ex_cmds.h, src/ex_docmd.c
Karsten Hopp 25b3f7
Karsten Hopp 25b3f7
Karsten Hopp 25b3f7
*** ../vim-7.2.434/src/eval.c	2010-05-14 20:41:00.000000000 +0200
Karsten Hopp 25b3f7
--- src/eval.c	2010-05-16 13:19:04.000000000 +0200
Karsten Hopp 25b3f7
***************
Karsten Hopp 25b3f7
*** 18309,18316 ****
Karsten Hopp 25b3f7
  # ifdef FEAT_MBYTE
Karsten Hopp 25b3f7
      if (eap->force_enc != 0)
Karsten Hopp 25b3f7
  	len += (unsigned)STRLEN(eap->cmd + eap->force_enc) + 7;
Karsten Hopp 25b3f7
!     if (eap->bad_char_idx != 0)
Karsten Hopp 25b3f7
! 	len += (unsigned)STRLEN(eap->cmd + eap->bad_char_idx) + 7;
Karsten Hopp 25b3f7
  # endif
Karsten Hopp 25b3f7
  
Karsten Hopp 25b3f7
      newval = alloc(len + 1);
Karsten Hopp 25b3f7
--- 18309,18316 ----
Karsten Hopp 25b3f7
  # ifdef FEAT_MBYTE
Karsten Hopp 25b3f7
      if (eap->force_enc != 0)
Karsten Hopp 25b3f7
  	len += (unsigned)STRLEN(eap->cmd + eap->force_enc) + 7;
Karsten Hopp 25b3f7
!     if (eap->bad_char != 0)
Karsten Hopp 25b3f7
! 	len += 7 + 4;  /* " ++bad=" + "keep" or "drop" */
Karsten Hopp 25b3f7
  # endif
Karsten Hopp 25b3f7
  
Karsten Hopp 25b3f7
      newval = alloc(len + 1);
Karsten Hopp 25b3f7
***************
Karsten Hopp 25b3f7
*** 18334,18342 ****
Karsten Hopp 25b3f7
      if (eap->force_enc != 0)
Karsten Hopp 25b3f7
  	sprintf((char *)newval + STRLEN(newval), " ++enc=%s",
Karsten Hopp 25b3f7
  					       eap->cmd + eap->force_enc);
Karsten Hopp 25b3f7
!     if (eap->bad_char_idx != 0)
Karsten Hopp 25b3f7
! 	sprintf((char *)newval + STRLEN(newval), " ++bad=%s",
Karsten Hopp 25b3f7
! 					       eap->cmd + eap->bad_char_idx);
Karsten Hopp 25b3f7
  # endif
Karsten Hopp 25b3f7
      vimvars[VV_CMDARG].vv_str = newval;
Karsten Hopp 25b3f7
      return oldval;
Karsten Hopp 25b3f7
--- 18334,18345 ----
Karsten Hopp 25b3f7
      if (eap->force_enc != 0)
Karsten Hopp 25b3f7
  	sprintf((char *)newval + STRLEN(newval), " ++enc=%s",
Karsten Hopp 25b3f7
  					       eap->cmd + eap->force_enc);
Karsten Hopp 25b3f7
!     if (eap->bad_char == BAD_KEEP)
Karsten Hopp 25b3f7
! 	STRCPY(newval + STRLEN(newval), " ++bad=keep");
Karsten Hopp 25b3f7
!     else if (eap->bad_char == BAD_DROP)
Karsten Hopp 25b3f7
! 	STRCPY(newval + STRLEN(newval), " ++bad=drop");
Karsten Hopp 25b3f7
!     else if (eap->bad_char != 0)
Karsten Hopp 25b3f7
! 	sprintf((char *)newval + STRLEN(newval), " ++bad=%c", eap->bad_char);
Karsten Hopp 25b3f7
  # endif
Karsten Hopp 25b3f7
      vimvars[VV_CMDARG].vv_str = newval;
Karsten Hopp 25b3f7
      return oldval;
Karsten Hopp 25b3f7
*** ../vim-7.2.434/src/ex_cmds.h	2010-05-14 20:41:00.000000000 +0200
Karsten Hopp 25b3f7
--- src/ex_cmds.h	2010-05-16 13:03:53.000000000 +0200
Karsten Hopp 25b3f7
***************
Karsten Hopp 25b3f7
*** 1152,1159 ****
Karsten Hopp 25b3f7
      int		force_ff;	/* ++ff= argument (index in cmd[]) */
Karsten Hopp 25b3f7
  #ifdef FEAT_MBYTE
Karsten Hopp 25b3f7
      int		force_enc;	/* ++enc= argument (index in cmd[]) */
Karsten Hopp 25b3f7
!     int		bad_char_idx;	/* ++bad= argument (index in cmd[]) */
Karsten Hopp 25b3f7
!     int		bad_char;	/* BAD_KEEP, BAD_DROP or replacement char */
Karsten Hopp 25b3f7
  #endif
Karsten Hopp 25b3f7
  #ifdef FEAT_USR_CMDS
Karsten Hopp 25b3f7
      int		useridx;	/* user command index */
Karsten Hopp 25b3f7
--- 1152,1158 ----
Karsten Hopp 25b3f7
      int		force_ff;	/* ++ff= argument (index in cmd[]) */
Karsten Hopp 25b3f7
  #ifdef FEAT_MBYTE
Karsten Hopp 25b3f7
      int		force_enc;	/* ++enc= argument (index in cmd[]) */
Karsten Hopp 25b3f7
!     int		bad_char;	/* BAD_KEEP, BAD_DROP or replacement byte */
Karsten Hopp 25b3f7
  #endif
Karsten Hopp 25b3f7
  #ifdef FEAT_USR_CMDS
Karsten Hopp 25b3f7
      int		useridx;	/* user command index */
Karsten Hopp 25b3f7
*** ../vim-7.2.434/src/ex_docmd.c	2010-05-14 20:41:00.000000000 +0200
Karsten Hopp 25b3f7
--- src/ex_docmd.c	2010-05-16 13:13:30.000000000 +0200
Karsten Hopp 25b3f7
***************
Karsten Hopp 25b3f7
*** 4688,4693 ****
Karsten Hopp 25b3f7
--- 4688,4694 ----
Karsten Hopp 25b3f7
      char_u	*arg = eap->arg + 2;
Karsten Hopp 25b3f7
      int		*pp = NULL;
Karsten Hopp 25b3f7
  #ifdef FEAT_MBYTE
Karsten Hopp 25b3f7
+     int		bad_char_idx;
Karsten Hopp 25b3f7
      char_u	*p;
Karsten Hopp 25b3f7
  #endif
Karsten Hopp 25b3f7
  
Karsten Hopp 25b3f7
***************
Karsten Hopp 25b3f7
*** 4739,4745 ****
Karsten Hopp 25b3f7
      else if (STRNCMP(arg, "bad", 3) == 0)
Karsten Hopp 25b3f7
      {
Karsten Hopp 25b3f7
  	arg += 3;
Karsten Hopp 25b3f7
! 	pp = &eap->bad_char_idx;
Karsten Hopp 25b3f7
      }
Karsten Hopp 25b3f7
  #endif
Karsten Hopp 25b3f7
  
Karsten Hopp 25b3f7
--- 4740,4746 ----
Karsten Hopp 25b3f7
      else if (STRNCMP(arg, "bad", 3) == 0)
Karsten Hopp 25b3f7
      {
Karsten Hopp 25b3f7
  	arg += 3;
Karsten Hopp 25b3f7
! 	pp = &bad_char_idx;
Karsten Hopp 25b3f7
      }
Karsten Hopp 25b3f7
  #endif
Karsten Hopp 25b3f7
  
Karsten Hopp 25b3f7
***************
Karsten Hopp 25b3f7
*** 4770,4776 ****
Karsten Hopp 25b3f7
      {
Karsten Hopp 25b3f7
  	/* Check ++bad= argument.  Must be a single-byte character, "keep" or
Karsten Hopp 25b3f7
  	 * "drop". */
Karsten Hopp 25b3f7
! 	p = eap->cmd + eap->bad_char_idx;
Karsten Hopp 25b3f7
  	if (STRICMP(p, "keep") == 0)
Karsten Hopp 25b3f7
  	    eap->bad_char = BAD_KEEP;
Karsten Hopp 25b3f7
  	else if (STRICMP(p, "drop") == 0)
Karsten Hopp 25b3f7
--- 4771,4777 ----
Karsten Hopp 25b3f7
      {
Karsten Hopp 25b3f7
  	/* Check ++bad= argument.  Must be a single-byte character, "keep" or
Karsten Hopp 25b3f7
  	 * "drop". */
Karsten Hopp 25b3f7
! 	p = eap->cmd + bad_char_idx;
Karsten Hopp 25b3f7
  	if (STRICMP(p, "keep") == 0)
Karsten Hopp 25b3f7
  	    eap->bad_char = BAD_KEEP;
Karsten Hopp 25b3f7
  	else if (STRICMP(p, "drop") == 0)
Karsten Hopp 25b3f7
*** ../vim-7.2.434/src/version.c	2010-05-16 12:32:37.000000000 +0200
Karsten Hopp 25b3f7
--- src/version.c	2010-05-16 13:24:39.000000000 +0200
Karsten Hopp 25b3f7
***************
Karsten Hopp 25b3f7
*** 683,684 ****
Karsten Hopp 25b3f7
--- 683,686 ----
Karsten Hopp 25b3f7
  {   /* Add new patch number below this line */
Karsten Hopp 25b3f7
+ /**/
Karsten Hopp 25b3f7
+     435,
Karsten Hopp 25b3f7
  /**/
Karsten Hopp 25b3f7
Karsten Hopp 25b3f7
-- 
Karsten Hopp 25b3f7
hundred-and-one symptoms of being an internet addict:
Karsten Hopp 25b3f7
45. You buy a Captain Kirk chair with a built-in keyboard and mouse.
Karsten Hopp 25b3f7
Karsten Hopp 25b3f7
 /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net   \\\
Karsten Hopp 25b3f7
///        sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
Karsten Hopp 25b3f7
\\\        download, build and distribute -- http://www.A-A-P.org        ///
Karsten Hopp 25b3f7
 \\\            help me help AIDS victims -- http://ICCF-Holland.org    ///