home *** CD-ROM | disk | FTP | other *** search
/ vim.ftp.fu-berlin.de / 2015-02-03.vim.ftp.fu-berlin.de.tar / vim.ftp.fu-berlin.de / patches / 5.7.028 < prev    next >
Encoding:
Internet Message Format  |  2001-04-02  |  3.5 KB

  1. To: vim-dev@vim.org
  2. Subject: Patch 5.7.028
  3. Fcc: outbox
  4. From: Bram Moolenaar <Bram@moolenaar.net>
  5. ------------
  6.  
  7. Patch 5.7.028
  8. Problem:    Creating a backup or swap file could fail in rare situations.
  9. Solution:   Use O_EXCL for open().
  10. Files:        src/fileio.c, src/memfile.c
  11.  
  12.  
  13. *** ../vim-5.7.27/src/fileio.c    Thu Mar 29 21:39:51 2001
  14. --- src/fileio.c    Fri Mar 30 12:11:30 2001
  15. ***************
  16. *** 1532,1538 ****
  17.           {
  18.           /* remove old backup, if present */
  19.           mch_remove(backup);
  20. !         bfd = mch_open((char *)backup, O_WRONLY|O_CREAT|O_EXTRA, 0666);
  21.           if (bfd < 0)
  22.           {
  23.               vim_free(backup);
  24. --- 1532,1539 ----
  25.           {
  26.           /* remove old backup, if present */
  27.           mch_remove(backup);
  28. !         bfd = mch_open((char *)backup, O_WRONLY|O_CREAT|O_EXCL|O_EXTRA,
  29. !                                     0666);
  30.           if (bfd < 0)
  31.           {
  32.               vim_free(backup);
  33. ***************
  34. *** 2147,2153 ****
  35.           int empty_fd;
  36.   
  37.           if (org == NULL
  38. !             || (empty_fd = mch_open(org, O_CREAT | O_EXTRA, 0666)) < 0)
  39.             EMSG("patchmode: can't touch empty original file");
  40.           else
  41.             close(empty_fd);
  42. --- 2148,2155 ----
  43.           int empty_fd;
  44.   
  45.           if (org == NULL
  46. !             || (empty_fd = mch_open(org, O_CREAT | O_EXTRA | O_EXCL,
  47. !                                    0666)) < 0)
  48.             EMSG("patchmode: can't touch empty original file");
  49.           else
  50.             close(empty_fd);
  51. ***************
  52. *** 2820,2826 ****
  53.       fd_in = mch_open((char *)from, O_RDONLY|O_EXTRA, 0);
  54.       if (fd_in == -1)
  55.       return -1;
  56. !     fd_out = mch_open((char *)to, O_CREAT|O_TRUNC|O_WRONLY|O_EXTRA, 0666);
  57.       if (fd_out == -1)
  58.       {
  59.       close(fd_in);
  60. --- 2822,2828 ----
  61.       fd_in = mch_open((char *)from, O_RDONLY|O_EXTRA, 0);
  62.       if (fd_in == -1)
  63.       return -1;
  64. !     fd_out = mch_open((char *)to, O_CREAT|O_EXCL|O_WRONLY|O_EXTRA, 0666);
  65.       if (fd_out == -1)
  66.       {
  67.       close(fd_in);
  68. *** ../vim-5.7.27/src/memfile.c    Tue Jan 11 16:19:43 2000
  69. --- src/memfile.c    Tue Apr  3 11:47:46 2001
  70. ***************
  71. *** 1213,1227 ****
  72.   #endif
  73.   
  74.       /*
  75. !      * try to open the file
  76.        */
  77.       mfp->mf_fd = open(
  78.   #ifdef VMS
  79.           vms_fixfilename(mfp->mf_fname),
  80.   #else
  81.           (char *)mfp->mf_fname,
  82.   #endif
  83. !         (trunc_file ? (O_CREAT | O_RDWR | O_TRUNC) : (O_RDONLY)) | O_EXTRA
  84.   #if defined(UNIX) || defined(RISCOS)         /* open in rw------- mode */
  85.               , (mode_t)0600
  86.   #endif
  87. --- 1213,1229 ----
  88.   #endif
  89.   
  90.       /*
  91. !      * Try to open the file.  First delete any existing file.
  92.        */
  93. +     if (trunc_file)
  94. +     mch_remove(mfp->mf_fname);
  95.       mfp->mf_fd = open(
  96.   #ifdef VMS
  97.           vms_fixfilename(mfp->mf_fname),
  98.   #else
  99.           (char *)mfp->mf_fname,
  100.   #endif
  101. !         (trunc_file ? (O_CREAT | O_RDWR | O_EXCL) : (O_RDONLY)) | O_EXTRA
  102.   #if defined(UNIX) || defined(RISCOS)         /* open in rw------- mode */
  103.               , (mode_t)0600
  104.   #endif
  105. *** ../vim-5.7.27/src/version.c    Thu Mar 29 21:39:51 2001
  106. --- src/version.c    Tue Apr  3 11:48:06 2001
  107. ***************
  108. *** 439,440 ****
  109. --- 439,442 ----
  110.   {   /* Add new patch number below this line */
  111. + /**/
  112. +     28,
  113.   /**/
  114.  
  115. -- 
  116. While it's true that many normal people whould prefer not to _date_ an
  117. engineer, most normal people harbor an intense desire to _mate_ with them,
  118. thus producing engineerlike children who will have high-paying jobs long
  119. before losing their virginity.
  120.                 (Scott Adams - The Dilbert principle)
  121.  
  122.  ///  Bram Moolenaar -- Bram@moolenaar.net -- http://www.moolenaar.net  \\\
  123. (((   Creator of Vim - http://www.vim.org -- ftp://ftp.vim.org/pub/vim   )))
  124.  \\\  Help me helping AIDS orphans in Uganda - http://iccf-holland.org  ///
  125.