Karsten Hopp fc7d30
To: vim-dev@vim.org
Karsten Hopp fc7d30
Subject: Patch 7.2.430
Karsten Hopp fc7d30
Fcc: outbox
Karsten Hopp fc7d30
From: Bram Moolenaar <Bram@moolenaar.net>
Karsten Hopp fc7d30
Mime-Version: 1.0
Karsten Hopp fc7d30
Content-Type: text/plain; charset=UTF-8
Karsten Hopp fc7d30
Content-Transfer-Encoding: 8bit
Karsten Hopp fc7d30
------------
Karsten Hopp fc7d30
Karsten Hopp fc7d30
Patch 7.2.430
Karsten Hopp fc7d30
Problem:    The ++bad argument is handled wrong, resulting in an invalid
Karsten Hopp fc7d30
	    memory access.
Karsten Hopp fc7d30
Solution:   Use the bad_char field only for the replacement character, add
Karsten Hopp fc7d30
	    bad_char_idx to store the position. (Dominique Pelle)
Karsten Hopp fc7d30
Files:	    src/eval.c, src/ex_cmds.h, src/ex_docmd.c
Karsten Hopp fc7d30
Karsten Hopp fc7d30
Karsten Hopp fc7d30
*** ../vim-7.2.429/src/eval.c	2010-05-14 12:16:19.000000000 +0200
Karsten Hopp fc7d30
--- src/eval.c	2010-05-14 19:04:53.000000000 +0200
Karsten Hopp fc7d30
***************
Karsten Hopp fc7d30
*** 18309,18316 ****
Karsten Hopp fc7d30
  # ifdef FEAT_MBYTE
Karsten Hopp fc7d30
      if (eap->force_enc != 0)
Karsten Hopp fc7d30
  	len += (unsigned)STRLEN(eap->cmd + eap->force_enc) + 7;
Karsten Hopp fc7d30
!     if (eap->bad_char != 0)
Karsten Hopp fc7d30
! 	len += (unsigned)STRLEN(eap->cmd + eap->bad_char) + 7;
Karsten Hopp fc7d30
  # endif
Karsten Hopp fc7d30
  
Karsten Hopp fc7d30
      newval = alloc(len + 1);
Karsten Hopp fc7d30
--- 18309,18316 ----
Karsten Hopp fc7d30
  # ifdef FEAT_MBYTE
Karsten Hopp fc7d30
      if (eap->force_enc != 0)
Karsten Hopp fc7d30
  	len += (unsigned)STRLEN(eap->cmd + eap->force_enc) + 7;
Karsten Hopp fc7d30
!     if (eap->bad_char_idx != 0)
Karsten Hopp fc7d30
! 	len += (unsigned)STRLEN(eap->cmd + eap->bad_char_idx) + 7;
Karsten Hopp fc7d30
  # endif
Karsten Hopp fc7d30
  
Karsten Hopp fc7d30
      newval = alloc(len + 1);
Karsten Hopp fc7d30
***************
Karsten Hopp fc7d30
*** 18334,18342 ****
Karsten Hopp fc7d30
      if (eap->force_enc != 0)
Karsten Hopp fc7d30
  	sprintf((char *)newval + STRLEN(newval), " ++enc=%s",
Karsten Hopp fc7d30
  					       eap->cmd + eap->force_enc);
Karsten Hopp fc7d30
!     if (eap->bad_char != 0)
Karsten Hopp fc7d30
  	sprintf((char *)newval + STRLEN(newval), " ++bad=%s",
Karsten Hopp fc7d30
! 					       eap->cmd + eap->bad_char);
Karsten Hopp fc7d30
  # endif
Karsten Hopp fc7d30
      vimvars[VV_CMDARG].vv_str = newval;
Karsten Hopp fc7d30
      return oldval;
Karsten Hopp fc7d30
--- 18334,18342 ----
Karsten Hopp fc7d30
      if (eap->force_enc != 0)
Karsten Hopp fc7d30
  	sprintf((char *)newval + STRLEN(newval), " ++enc=%s",
Karsten Hopp fc7d30
  					       eap->cmd + eap->force_enc);
Karsten Hopp fc7d30
!     if (eap->bad_char_idx != 0)
Karsten Hopp fc7d30
  	sprintf((char *)newval + STRLEN(newval), " ++bad=%s",
Karsten Hopp fc7d30
! 					       eap->cmd + eap->bad_char_idx);
Karsten Hopp fc7d30
  # endif
Karsten Hopp fc7d30
      vimvars[VV_CMDARG].vv_str = newval;
Karsten Hopp fc7d30
      return oldval;
Karsten Hopp fc7d30
*** ../vim-7.2.429/src/ex_cmds.h	2010-05-14 15:42:49.000000000 +0200
Karsten Hopp fc7d30
--- src/ex_cmds.h	2010-05-14 20:23:20.000000000 +0200
Karsten Hopp fc7d30
***************
Karsten Hopp fc7d30
*** 1152,1158 ****
Karsten Hopp fc7d30
      int		force_ff;	/* ++ff= argument (index in cmd[]) */
Karsten Hopp fc7d30
  #ifdef FEAT_MBYTE
Karsten Hopp fc7d30
      int		force_enc;	/* ++enc= argument (index in cmd[]) */
Karsten Hopp fc7d30
!     int		bad_char;	/* ++bad= argument (index in cmd[]) */
Karsten Hopp fc7d30
  #endif
Karsten Hopp fc7d30
  #ifdef FEAT_USR_CMDS
Karsten Hopp fc7d30
      int		useridx;	/* user command index */
Karsten Hopp fc7d30
--- 1152,1159 ----
Karsten Hopp fc7d30
      int		force_ff;	/* ++ff= argument (index in cmd[]) */
Karsten Hopp fc7d30
  #ifdef FEAT_MBYTE
Karsten Hopp fc7d30
      int		force_enc;	/* ++enc= argument (index in cmd[]) */
Karsten Hopp fc7d30
!     int		bad_char_idx;	/* ++bad= argument (index in cmd[]) */
Karsten Hopp fc7d30
!     int		bad_char;	/* BAD_KEEP, BAD_DROP or replacement char */
Karsten Hopp fc7d30
  #endif
Karsten Hopp fc7d30
  #ifdef FEAT_USR_CMDS
Karsten Hopp fc7d30
      int		useridx;	/* user command index */
Karsten Hopp fc7d30
*** ../vim-7.2.429/src/ex_docmd.c	2010-05-14 15:28:37.000000000 +0200
Karsten Hopp fc7d30
--- src/ex_docmd.c	2010-05-14 19:04:53.000000000 +0200
Karsten Hopp fc7d30
***************
Karsten Hopp fc7d30
*** 4739,4745 ****
Karsten Hopp fc7d30
      else if (STRNCMP(arg, "bad", 3) == 0)
Karsten Hopp fc7d30
      {
Karsten Hopp fc7d30
  	arg += 3;
Karsten Hopp fc7d30
! 	pp = &eap->bad_char;
Karsten Hopp fc7d30
      }
Karsten Hopp fc7d30
  #endif
Karsten Hopp fc7d30
  
Karsten Hopp fc7d30
--- 4739,4745 ----
Karsten Hopp fc7d30
      else if (STRNCMP(arg, "bad", 3) == 0)
Karsten Hopp fc7d30
      {
Karsten Hopp fc7d30
  	arg += 3;
Karsten Hopp fc7d30
! 	pp = &eap->bad_char_idx;
Karsten Hopp fc7d30
      }
Karsten Hopp fc7d30
  #endif
Karsten Hopp fc7d30
  
Karsten Hopp fc7d30
***************
Karsten Hopp fc7d30
*** 4770,4776 ****
Karsten Hopp fc7d30
      {
Karsten Hopp fc7d30
  	/* Check ++bad= argument.  Must be a single-byte character, "keep" or
Karsten Hopp fc7d30
  	 * "drop". */
Karsten Hopp fc7d30
! 	p = eap->cmd + eap->bad_char;
Karsten Hopp fc7d30
  	if (STRICMP(p, "keep") == 0)
Karsten Hopp fc7d30
  	    eap->bad_char = BAD_KEEP;
Karsten Hopp fc7d30
  	else if (STRICMP(p, "drop") == 0)
Karsten Hopp fc7d30
--- 4770,4776 ----
Karsten Hopp fc7d30
      {
Karsten Hopp fc7d30
  	/* Check ++bad= argument.  Must be a single-byte character, "keep" or
Karsten Hopp fc7d30
  	 * "drop". */
Karsten Hopp fc7d30
! 	p = eap->cmd + eap->bad_char_idx;
Karsten Hopp fc7d30
  	if (STRICMP(p, "keep") == 0)
Karsten Hopp fc7d30
  	    eap->bad_char = BAD_KEEP;
Karsten Hopp fc7d30
  	else if (STRICMP(p, "drop") == 0)
Karsten Hopp fc7d30
*** ../vim-7.2.429/src/version.c	2010-05-14 18:56:33.000000000 +0200
Karsten Hopp fc7d30
--- src/version.c	2010-05-14 20:39:38.000000000 +0200
Karsten Hopp fc7d30
***************
Karsten Hopp fc7d30
*** 683,684 ****
Karsten Hopp fc7d30
--- 683,686 ----
Karsten Hopp fc7d30
  {   /* Add new patch number below this line */
Karsten Hopp fc7d30
+ /**/
Karsten Hopp fc7d30
+     430,
Karsten Hopp fc7d30
  /**/
Karsten Hopp fc7d30
Karsten Hopp fc7d30
-- 
Karsten Hopp fc7d30
You have the right to remain silent. Anything you say will be
Karsten Hopp fc7d30
misquoted, then used against you.
Karsten Hopp fc7d30
Karsten Hopp fc7d30
 /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net   \\\
Karsten Hopp fc7d30
///        sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
Karsten Hopp fc7d30
\\\        download, build and distribute -- http://www.A-A-P.org        ///
Karsten Hopp fc7d30
 \\\            help me help AIDS victims -- http://ICCF-Holland.org    ///