Karsten Hopp 7ca41a
To: vim_dev@googlegroups.com
Karsten Hopp 7ca41a
Subject: Patch 7.3.1038
Karsten Hopp 7ca41a
Fcc: outbox
Karsten Hopp 7ca41a
From: Bram Moolenaar <Bram@moolenaar.net>
Karsten Hopp 7ca41a
Mime-Version: 1.0
Karsten Hopp 7ca41a
Content-Type: text/plain; charset=UTF-8
Karsten Hopp 7ca41a
Content-Transfer-Encoding: 8bit
Karsten Hopp 7ca41a
------------
Karsten Hopp 7ca41a
Karsten Hopp 7ca41a
Patch 7.3.1038
Karsten Hopp 7ca41a
Problem:    Crash when using Cscope.
Karsten Hopp 7ca41a
Solution:   Avoid negative argument to vim_strncpy(). (Narendran
Karsten Hopp 7ca41a
	    Gopalakrishnan)
Karsten Hopp 7ca41a
Files:	    src/if_cscope.c
Karsten Hopp 7ca41a
Karsten Hopp 7ca41a
Karsten Hopp 7ca41a
*** ../vim-7.3.1037/src/if_cscope.c	2013-05-06 04:21:35.000000000 +0200
Karsten Hopp 7ca41a
--- src/if_cscope.c	2013-05-29 19:12:55.000000000 +0200
Karsten Hopp 7ca41a
***************
Karsten Hopp 7ca41a
*** 2460,2472 ****
Karsten Hopp 7ca41a
  /*
Karsten Hopp 7ca41a
   * PRIVATE: cs_resolve_file
Karsten Hopp 7ca41a
   *
Karsten Hopp 7ca41a
!  * construct the full pathname to a file found in the cscope database.
Karsten Hopp 7ca41a
   * (Prepends ppath, if there is one and if it's not already prepended,
Karsten Hopp 7ca41a
   * otherwise just uses the name found.)
Karsten Hopp 7ca41a
   *
Karsten Hopp 7ca41a
!  * we need to prepend the prefix because on some cscope's (e.g., the one that
Karsten Hopp 7ca41a
   * ships with Solaris 2.6), the output never has the prefix prepended.
Karsten Hopp 7ca41a
!  * contrast this with my development system (Digital Unix), which does.
Karsten Hopp 7ca41a
   */
Karsten Hopp 7ca41a
      static char *
Karsten Hopp 7ca41a
  cs_resolve_file(i, name)
Karsten Hopp 7ca41a
--- 2460,2472 ----
Karsten Hopp 7ca41a
  /*
Karsten Hopp 7ca41a
   * PRIVATE: cs_resolve_file
Karsten Hopp 7ca41a
   *
Karsten Hopp 7ca41a
!  * Construct the full pathname to a file found in the cscope database.
Karsten Hopp 7ca41a
   * (Prepends ppath, if there is one and if it's not already prepended,
Karsten Hopp 7ca41a
   * otherwise just uses the name found.)
Karsten Hopp 7ca41a
   *
Karsten Hopp 7ca41a
!  * We need to prepend the prefix because on some cscope's (e.g., the one that
Karsten Hopp 7ca41a
   * ships with Solaris 2.6), the output never has the prefix prepended.
Karsten Hopp 7ca41a
!  * Contrast this with my development system (Digital Unix), which does.
Karsten Hopp 7ca41a
   */
Karsten Hopp 7ca41a
      static char *
Karsten Hopp 7ca41a
  cs_resolve_file(i, name)
Karsten Hopp 7ca41a
***************
Karsten Hopp 7ca41a
*** 2493,2506 ****
Karsten Hopp 7ca41a
  	if (csdir != NULL)
Karsten Hopp 7ca41a
  	{
Karsten Hopp 7ca41a
  	    vim_strncpy(csdir, (char_u *)csinfo[i].fname,
Karsten Hopp 7ca41a
! 		    gettail((char_u *)csinfo[i].fname) - 1 - (char_u *)csinfo[i].fname);
Karsten Hopp 7ca41a
  	    len += (int)STRLEN(csdir);
Karsten Hopp 7ca41a
  	}
Karsten Hopp 7ca41a
      }
Karsten Hopp 7ca41a
  
Karsten Hopp 7ca41a
-     if ((fullname = (char *)alloc(len)) == NULL)
Karsten Hopp 7ca41a
- 	return NULL;
Karsten Hopp 7ca41a
- 
Karsten Hopp 7ca41a
      /* Note/example: this won't work if the cscope output already starts
Karsten Hopp 7ca41a
       * "../.." and the prefix path is also "../..".  if something like this
Karsten Hopp 7ca41a
       * happens, you are screwed up and need to fix how you're using cscope. */
Karsten Hopp 7ca41a
--- 2493,2504 ----
Karsten Hopp 7ca41a
  	if (csdir != NULL)
Karsten Hopp 7ca41a
  	{
Karsten Hopp 7ca41a
  	    vim_strncpy(csdir, (char_u *)csinfo[i].fname,
Karsten Hopp 7ca41a
! 		                       gettail((char_u *)csinfo[i].fname)
Karsten Hopp 7ca41a
! 						 - (char_u *)csinfo[i].fname);
Karsten Hopp 7ca41a
  	    len += (int)STRLEN(csdir);
Karsten Hopp 7ca41a
  	}
Karsten Hopp 7ca41a
      }
Karsten Hopp 7ca41a
  
Karsten Hopp 7ca41a
      /* Note/example: this won't work if the cscope output already starts
Karsten Hopp 7ca41a
       * "../.." and the prefix path is also "../..".  if something like this
Karsten Hopp 7ca41a
       * happens, you are screwed up and need to fix how you're using cscope. */
Karsten Hopp 7ca41a
***************
Karsten Hopp 7ca41a
*** 2511,2526 ****
Karsten Hopp 7ca41a
  	    && name[0] != '\\' && name[1] != ':'
Karsten Hopp 7ca41a
  #endif
Karsten Hopp 7ca41a
         )
Karsten Hopp 7ca41a
! 	(void)sprintf(fullname, "%s/%s", csinfo[i].ppath, name);
Karsten Hopp 7ca41a
!     else if (csdir != NULL && csinfo[i].fname != NULL && STRLEN(csdir) > 0)
Karsten Hopp 7ca41a
      {
Karsten Hopp 7ca41a
  	/* Check for csdir to be non empty to avoid empty path concatenated to
Karsten Hopp 7ca41a
! 	 * cscope output. TODO: avoid the unnecessary alloc/free of fullname. */
Karsten Hopp 7ca41a
! 	vim_free(fullname);
Karsten Hopp 7ca41a
  	fullname = (char *)concat_fnames(csdir, (char_u *)name, TRUE);
Karsten Hopp 7ca41a
      }
Karsten Hopp 7ca41a
      else
Karsten Hopp 7ca41a
! 	(void)sprintf(fullname, "%s", name);
Karsten Hopp 7ca41a
  
Karsten Hopp 7ca41a
      vim_free(csdir);
Karsten Hopp 7ca41a
      return fullname;
Karsten Hopp 7ca41a
--- 2509,2528 ----
Karsten Hopp 7ca41a
  	    && name[0] != '\\' && name[1] != ':'
Karsten Hopp 7ca41a
  #endif
Karsten Hopp 7ca41a
         )
Karsten Hopp 7ca41a
!     {
Karsten Hopp 7ca41a
! 	if ((fullname = (char *)alloc(len)) != NULL)
Karsten Hopp 7ca41a
! 	    (void)sprintf(fullname, "%s/%s", csinfo[i].ppath, name);
Karsten Hopp 7ca41a
!     }
Karsten Hopp 7ca41a
!     else if (csdir != NULL && csinfo[i].fname != NULL && *csdir != NUL)
Karsten Hopp 7ca41a
      {
Karsten Hopp 7ca41a
  	/* Check for csdir to be non empty to avoid empty path concatenated to
Karsten Hopp 7ca41a
! 	 * cscope output. */
Karsten Hopp 7ca41a
  	fullname = (char *)concat_fnames(csdir, (char_u *)name, TRUE);
Karsten Hopp 7ca41a
      }
Karsten Hopp 7ca41a
      else
Karsten Hopp 7ca41a
!     {
Karsten Hopp 7ca41a
! 	fullname = (char *)vim_strsave((char_u *)name);
Karsten Hopp 7ca41a
!     }
Karsten Hopp 7ca41a
  
Karsten Hopp 7ca41a
      vim_free(csdir);
Karsten Hopp 7ca41a
      return fullname;
Karsten Hopp 7ca41a
*** ../vim-7.3.1037/src/version.c	2013-05-29 18:45:07.000000000 +0200
Karsten Hopp 7ca41a
--- src/version.c	2013-05-29 19:17:16.000000000 +0200
Karsten Hopp 7ca41a
***************
Karsten Hopp 7ca41a
*** 730,731 ****
Karsten Hopp 7ca41a
--- 730,733 ----
Karsten Hopp 7ca41a
  {   /* Add new patch number below this line */
Karsten Hopp 7ca41a
+ /**/
Karsten Hopp 7ca41a
+     1038,
Karsten Hopp 7ca41a
  /**/
Karsten Hopp 7ca41a
Karsten Hopp 7ca41a
-- 
Karsten Hopp 7ca41a
hundred-and-one symptoms of being an internet addict:
Karsten Hopp 7ca41a
12. You turn off your modem and get this awful empty feeling, like you just
Karsten Hopp 7ca41a
    pulled the plug on a loved one.
Karsten Hopp 7ca41a
Karsten Hopp 7ca41a
 /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net   \\\
Karsten Hopp 7ca41a
///        sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
Karsten Hopp 7ca41a
\\\  an exciting new programming language -- http://www.Zimbu.org        ///
Karsten Hopp 7ca41a
 \\\            help me help AIDS victims -- http://ICCF-Holland.org    ///