c165266
To: vim-dev@vim.org
c165266
Subject: Patch 7.2.044
c165266
Fcc: outbox
c165266
From: Bram Moolenaar <Bram@moolenaar.net>
c165266
Mime-Version: 1.0
c165266
Content-Type: text/plain; charset=ISO-8859-1
c165266
Content-Transfer-Encoding: 8bit
c165266
------------
c165266
c165266
Patch 7.2.044
c165266
Problem:    Crash because of STRCPY() being over protective of the destination
c165266
	    size. (Dominique Pelle)
c165266
Solution:   Add -D_FORTIFY_SOURCE=1 to CFLAGS.  Use an intermediate variable
c165266
	    for the pointer to avoid a warning.
c165266
Files:	    src/auto/configure, src/configure.in, src/eval.c
c165266
c165266
c165266
*** ../vim-7.2.043/src/auto/configure	Thu Jul 24 17:20:50 2008
c165266
--- src/auto/configure	Sun Nov 16 17:08:44 2008
c165266
***************
c165266
*** 16819,16839 ****
c165266
    LDFLAGS="$LDFLAGS -isysroot /Developer/SDKs/MacOSX10.4u.sdk -arch i386 -arch ppc"
c165266
  fi
c165266
  
c165266
- { $as_echo "$as_me:$LINENO: checking for GCC 3 or later" >&5
c165266
- $as_echo_n "checking for GCC 3 or later... " >&6; }
c165266
  DEPEND_CFLAGS_FILTER=
c165266
  if test "$GCC" = yes; then
c165266
    gccmajor=`echo "$gccversion" | sed -e 's/^\([1-9]\)\..*$/\1/g'`
c165266
    if test "$gccmajor" -gt "2"; then
c165266
      DEPEND_CFLAGS_FILTER="| sed 's+-I */+-isystem /+g'"
c165266
!   fi
c165266
! fi
c165266
! if test "$DEPEND_CFLAGS_FILTER" = ""; then
c165266
!   { $as_echo "$as_me:$LINENO: result: no" >&5
c165266
  $as_echo "no" >&6; }
c165266
! else
c165266
!   { $as_echo "$as_me:$LINENO: result: yes" >&5
c165266
  $as_echo "yes" >&6; }
c165266
  fi
c165266
  
c165266
  
c165266
--- 16819,16847 ----
c165266
    LDFLAGS="$LDFLAGS -isysroot /Developer/SDKs/MacOSX10.4u.sdk -arch i386 -arch ppc"
c165266
  fi
c165266
  
c165266
  DEPEND_CFLAGS_FILTER=
c165266
  if test "$GCC" = yes; then
c165266
+   { $as_echo "$as_me:$LINENO: checking for GCC 3 or later" >&5
c165266
+ $as_echo_n "checking for GCC 3 or later... " >&6; }
c165266
    gccmajor=`echo "$gccversion" | sed -e 's/^\([1-9]\)\..*$/\1/g'`
c165266
    if test "$gccmajor" -gt "2"; then
c165266
      DEPEND_CFLAGS_FILTER="| sed 's+-I */+-isystem /+g'"
c165266
!     { $as_echo "$as_me:$LINENO: result: yes" >&5
c165266
! $as_echo "yes" >&6; }
c165266
!   else
c165266
!     { $as_echo "$as_me:$LINENO: result: no" >&5
c165266
  $as_echo "no" >&6; }
c165266
!   fi
c165266
!       { $as_echo "$as_me:$LINENO: checking whether we need -D_FORTIFY_SOURCE=1" >&5
c165266
! $as_echo_n "checking whether we need -D_FORTIFY_SOURCE=1... " >&6; }
c165266
!   if test "$gccmajor" -gt "3"; then
c165266
!     CFLAGS="$CFLAGS -D_FORTIFY_SOURCE=1"
c165266
!     { $as_echo "$as_me:$LINENO: result: yes" >&5
c165266
  $as_echo "yes" >&6; }
c165266
+   else
c165266
+     { $as_echo "$as_me:$LINENO: result: no" >&5
c165266
+ $as_echo "no" >&6; }
c165266
+   fi
c165266
  fi
c165266
  
c165266
  
c165266
*** ../vim-7.2.043/src/configure.in	Thu Jul 24 17:20:31 2008
c165266
--- src/configure.in	Sun Nov 16 17:08:40 2008
c165266
***************
c165266
*** 3152,3169 ****
c165266
  dnl But only when making dependencies, cproto and lint don't take "-isystem".
c165266
  dnl Mac gcc returns "powerpc-apple-darwin8-gcc-4.0.1 (GCC)...", need to allow
c165266
  dnl the number before the version number.
c165266
- AC_MSG_CHECKING(for GCC 3 or later)
c165266
  DEPEND_CFLAGS_FILTER=
c165266
  if test "$GCC" = yes; then
c165266
    gccmajor=`echo "$gccversion" | sed -e 's/^\([[1-9]]\)\..*$/\1/g'`
c165266
    if test "$gccmajor" -gt "2"; then
c165266
      DEPEND_CFLAGS_FILTER="| sed 's+-I */+-isystem /+g'"
c165266
    fi
c165266
- fi
c165266
- if test "$DEPEND_CFLAGS_FILTER" = ""; then
c165266
-   AC_MSG_RESULT(no)
c165266
- else
c165266
-   AC_MSG_RESULT(yes)
c165266
  fi
c165266
  AC_SUBST(DEPEND_CFLAGS_FILTER)
c165266
  
c165266
--- 3152,3176 ----
c165266
  dnl But only when making dependencies, cproto and lint don't take "-isystem".
c165266
  dnl Mac gcc returns "powerpc-apple-darwin8-gcc-4.0.1 (GCC)...", need to allow
c165266
  dnl the number before the version number.
c165266
  DEPEND_CFLAGS_FILTER=
c165266
  if test "$GCC" = yes; then
c165266
+   AC_MSG_CHECKING(for GCC 3 or later)
c165266
    gccmajor=`echo "$gccversion" | sed -e 's/^\([[1-9]]\)\..*$/\1/g'`
c165266
    if test "$gccmajor" -gt "2"; then
c165266
      DEPEND_CFLAGS_FILTER="| sed 's+-I */+-isystem /+g'"
c165266
+     AC_MSG_RESULT(yes)
c165266
+   else
c165266
+     AC_MSG_RESULT(no)
c165266
+   fi
c165266
+   dnl -D_FORTIFY_SOURCE=2 crashes Vim on strcpy(buf, "000") when buf is
c165266
+   dnl declared as char x[1] but actually longer.  Introduced in gcc 4.0.
c165266
+   AC_MSG_CHECKING(whether we need -D_FORTIFY_SOURCE=1)
c165266
+   if test "$gccmajor" -gt "3"; then
c165266
+     CFLAGS="$CFLAGS -D_FORTIFY_SOURCE=1"
c165266
+     AC_MSG_RESULT(yes)
c165266
+   else
c165266
+     AC_MSG_RESULT(no)
c165266
    fi
c165266
  fi
c165266
  AC_SUBST(DEPEND_CFLAGS_FILTER)
c165266
  
c165266
*** ../vim-7.2.043/src/eval.c	Wed Nov 12 15:28:37 2008
c165266
--- src/eval.c	Sun Nov 16 20:46:28 2008
c165266
***************
c165266
*** 21150,21157 ****
c165266
      init_var_dict(&fc.l_avars, &fc.l_avars_var);
c165266
      add_nr_var(&fc.l_avars, &fc.fixvar[fixvar_idx++].var, "0",
c165266
  				(varnumber_T)(argcount - fp->uf_args.ga_len));
c165266
      v = &fc.fixvar[fixvar_idx++].var;
c165266
!     STRCPY(v->di_key, "000");
c165266
      v->di_flags = DI_FLAGS_RO | DI_FLAGS_FIX;
c165266
      hash_add(&fc.l_avars.dv_hashtab, DI2HIKEY(v));
c165266
      v->di_tv.v_type = VAR_LIST;
c165266
--- 21150,21160 ----
c165266
      init_var_dict(&fc.l_avars, &fc.l_avars_var);
c165266
      add_nr_var(&fc.l_avars, &fc.fixvar[fixvar_idx++].var, "0",
c165266
  				(varnumber_T)(argcount - fp->uf_args.ga_len));
c165266
+     /* Use "name" to avoid a warning from some compiler that checks the
c165266
+      * destination size. */
c165266
      v = &fc.fixvar[fixvar_idx++].var;
c165266
!     name = v->di_key;
c165266
!     STRCPY(name, "000");
c165266
      v->di_flags = DI_FLAGS_RO | DI_FLAGS_FIX;
c165266
      hash_add(&fc.l_avars.dv_hashtab, DI2HIKEY(v));
c165266
      v->di_tv.v_type = VAR_LIST;
c165266
*** ../vim-7.2.043/src/version.c	Thu Nov 20 10:26:19 2008
c165266
--- src/version.c	Thu Nov 20 10:34:31 2008
c165266
***************
c165266
*** 678,679 ****
c165266
--- 678,681 ----
c165266
  {   /* Add new patch number below this line */
c165266
+ /**/
c165266
+     44,
c165266
  /**/
c165266
c165266
-- 
c165266
Error:015 - Unable to exit Windows.  Try the door.
c165266
c165266
 /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net   \\\
c165266
///        sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
c165266
\\\        download, build and distribute -- http://www.A-A-P.org        ///
c165266
 \\\            help me help AIDS victims -- http://ICCF-Holland.org    ///