Patch 9.0.0119
Problem: Tiny chance that creating a backup file fails.
Solution: Check for EEXIST error. (Ken Takata, closes #10821)
Files: src/bufwrite.c
*** ../vim-9.0.0118/src/bufwrite.c 2022-05-09 19:06:06.000000000 +0100
--- src/bufwrite.c 2022-07-31 11:47:43.353783544 +0100
***************
*** 1208,1221 ****
// First find a file name that doesn't exist yet (use some
// arbitrary numbers).
STRCPY(IObuff, fname);
for (i = 4913; ; i += 123)
{
sprintf((char *)gettail(IObuff), "%d", i);
if (mch_lstat((char *)IObuff, &st) < 0)
break;
}
- fd = mch_open((char *)IObuff,
- O_CREAT|O_WRONLY|O_EXCL|O_NOFOLLOW, perm);
if (fd < 0) // can't write in directory
backup_copy = TRUE;
else
--- 1208,1229 ----
// First find a file name that doesn't exist yet (use some
// arbitrary numbers).
STRCPY(IObuff, fname);
+ fd = -1;
for (i = 4913; ; i += 123)
{
sprintf((char *)gettail(IObuff), "%d", i);
if (mch_lstat((char *)IObuff, &st) < 0)
+ {
+ fd = mch_open((char *)IObuff,
+ O_CREAT|O_WRONLY|O_EXCL|O_NOFOLLOW, perm);
+ if (fd < 0 && errno == EEXIST)
+ // If the same file name is created by another
+ // process between lstat() and open(), find another
+ // name.
+ continue;
break;
+ }
}
if (fd < 0) // can't write in directory
backup_copy = TRUE;
else
*** ../vim-9.0.0118/src/version.c 2022-07-31 11:37:16.451058499 +0100
--- src/version.c 2022-07-31 11:50:05.289659017 +0100
***************
*** 737,738 ****
--- 737,740 ----
{ /* Add new patch number below this line */
+ /**/
+ 119,
/**/
--
hundred-and-one symptoms of being an internet addict:
203. You're an active member of more than 20 newsgroups.
/// Bram Moolenaar -- [email protected] -- http://www.Moolenaar.net \\\
/// \\\
\\\ sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ ///
\\\ help me help AIDS victims -- http://ICCF-Holland.org ///
--
--
You received this message from the "vim_dev" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php
---
You received this message because you are subscribed to the Google Groups
"vim_dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/vim_dev/20220731105116.CD3851C0C11%40moolenaar.net.