Karsten Hopp f1bc59
To: vim-dev@vim.org
Karsten Hopp f1bc59
Subject: Patch 7.0.127
Karsten Hopp f1bc59
Fcc: outbox
Karsten Hopp f1bc59
From: Bram Moolenaar <Bram@moolenaar.net>
Karsten Hopp f1bc59
Mime-Version: 1.0
Karsten Hopp f1bc59
Content-Type: text/plain; charset=ISO-8859-1
Karsten Hopp f1bc59
Content-Transfer-Encoding: 8bit
Karsten Hopp f1bc59
------------
Karsten Hopp f1bc59
Karsten Hopp f1bc59
Patch 7.0.127
Karsten Hopp f1bc59
Problem:    Crash when swap files has invalid timestamp.
Karsten Hopp f1bc59
Solution:   Check return value of ctime() for being NULL.
Karsten Hopp f1bc59
Files:	    src/memline.c
Karsten Hopp f1bc59
Karsten Hopp f1bc59
Karsten Hopp f1bc59
*** ../vim-7.0.126/src/memline.c	Tue Aug 29 17:28:56 2006
Karsten Hopp f1bc59
--- src/memline.c	Tue Oct 10 16:19:56 2006
Karsten Hopp f1bc59
***************
Karsten Hopp f1bc59
*** 1633,1638 ****
Karsten Hopp f1bc59
--- 1633,1639 ----
Karsten Hopp f1bc59
      int		    fd;
Karsten Hopp f1bc59
      struct block0   b0;
Karsten Hopp f1bc59
      time_t	    x = (time_t)0;
Karsten Hopp f1bc59
+     char	    *p;
Karsten Hopp f1bc59
  #ifdef UNIX
Karsten Hopp f1bc59
      char_u	    uname[B0_UNAME_SIZE];
Karsten Hopp f1bc59
  #endif
Karsten Hopp f1bc59
***************
Karsten Hopp f1bc59
*** 1652,1659 ****
Karsten Hopp f1bc59
  #endif
Karsten Hopp f1bc59
  	    MSG_PUTS(_("             dated: "));
Karsten Hopp f1bc59
  	x = st.st_mtime;		    /* Manx C can't do &st.st_mtime */
Karsten Hopp f1bc59
! 	MSG_PUTS(ctime(&x);;		    /* includes '\n' */
Karsten Hopp f1bc59
! 
Karsten Hopp f1bc59
      }
Karsten Hopp f1bc59
  
Karsten Hopp f1bc59
      /*
Karsten Hopp f1bc59
--- 1653,1663 ----
Karsten Hopp f1bc59
  #endif
Karsten Hopp f1bc59
  	    MSG_PUTS(_("             dated: "));
Karsten Hopp f1bc59
  	x = st.st_mtime;		    /* Manx C can't do &st.st_mtime */
Karsten Hopp f1bc59
! 	p = ctime(&x);			    /* includes '\n' */
Karsten Hopp f1bc59
! 	if (p == NULL)
Karsten Hopp f1bc59
! 	    MSG_PUTS("(invalid)\n");
Karsten Hopp f1bc59
! 	else
Karsten Hopp f1bc59
! 	    MSG_PUTS(p);
Karsten Hopp f1bc59
      }
Karsten Hopp f1bc59
  
Karsten Hopp f1bc59
      /*
Karsten Hopp f1bc59
***************
Karsten Hopp f1bc59
*** 3652,3657 ****
Karsten Hopp f1bc59
--- 3656,3662 ----
Karsten Hopp f1bc59
  {
Karsten Hopp f1bc59
      struct stat st;
Karsten Hopp f1bc59
      time_t	x, sx;
Karsten Hopp f1bc59
+     char	*p;
Karsten Hopp f1bc59
  
Karsten Hopp f1bc59
      ++no_wait_return;
Karsten Hopp f1bc59
      (void)EMSG(_("E325: ATTENTION"));
Karsten Hopp f1bc59
***************
Karsten Hopp f1bc59
*** 3666,3672 ****
Karsten Hopp f1bc59
      {
Karsten Hopp f1bc59
  	MSG_PUTS(_("             dated: "));
Karsten Hopp f1bc59
  	x = st.st_mtime;    /* Manx C can't do &st.st_mtime */
Karsten Hopp f1bc59
! 	MSG_PUTS(ctime(&x);;
Karsten Hopp f1bc59
  	if (sx != 0 && x > sx)
Karsten Hopp f1bc59
  	    MSG_PUTS(_("      NEWER than swap file!\n"));
Karsten Hopp f1bc59
      }
Karsten Hopp f1bc59
--- 3671,3681 ----
Karsten Hopp f1bc59
      {
Karsten Hopp f1bc59
  	MSG_PUTS(_("             dated: "));
Karsten Hopp f1bc59
  	x = st.st_mtime;    /* Manx C can't do &st.st_mtime */
Karsten Hopp f1bc59
! 	p = ctime(&x);			    /* includes '\n' */
Karsten Hopp f1bc59
! 	if (p == NULL)
Karsten Hopp f1bc59
! 	    MSG_PUTS("(invalid)\n");
Karsten Hopp f1bc59
! 	else
Karsten Hopp f1bc59
! 	    MSG_PUTS(p);
Karsten Hopp f1bc59
  	if (sx != 0 && x > sx)
Karsten Hopp f1bc59
  	    MSG_PUTS(_("      NEWER than swap file!\n"));
Karsten Hopp f1bc59
      }
Karsten Hopp f1bc59
*** ../vim-7.0.126/src/version.c	Tue Oct 10 15:49:41 2006
Karsten Hopp f1bc59
--- src/version.c	Tue Oct 10 16:18:51 2006
Karsten Hopp f1bc59
***************
Karsten Hopp f1bc59
*** 668,669 ****
Karsten Hopp f1bc59
--- 668,671 ----
Karsten Hopp f1bc59
  {   /* Add new patch number below this line */
Karsten Hopp f1bc59
+ /**/
Karsten Hopp f1bc59
+     127,
Karsten Hopp f1bc59
  /**/
Karsten Hopp f1bc59
Karsten Hopp f1bc59
-- 
Karsten Hopp f1bc59
How To Keep A Healthy Level Of Insanity:
Karsten Hopp f1bc59
17. When the money comes out the ATM, scream "I won!, I won! 3rd
Karsten Hopp f1bc59
    time this week!!!!!"
Karsten Hopp f1bc59
Karsten Hopp f1bc59
 /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net   \\\
Karsten Hopp f1bc59
///        sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
Karsten Hopp f1bc59
\\\        download, build and distribute -- http://www.A-A-P.org        ///
Karsten Hopp f1bc59
 \\\            help me help AIDS victims -- http://ICCF-Holland.org    ///