summaryrefslogtreecommitdiffstats
path: root/generic
diff options
context:
space:
mode:
authorsebres <sebres@users.sourceforge.net>2018-04-06 17:28:56 (GMT)
committersebres <sebres@users.sourceforge.net>2018-04-06 17:28:56 (GMT)
commit9077b8ce60cdb2f2b4f9f4dc518cc8bf4d8268b5 (patch)
tree750d944f1d62c0029b314b6e4b39cb056d5a1dbc /generic
parentda169b1600f14d5ab924ceefb6383c2a0062e80d (diff)
downloadtcl-9077b8ce60cdb2f2b4f9f4dc518cc8bf4d8268b5.zip
tcl-9077b8ce60cdb2f2b4f9f4dc518cc8bf4d8268b5.tar.gz
tcl-9077b8ce60cdb2f2b4f9f4dc518cc8bf4d8268b5.tar.bz2
[27b682284974d0cd] command "file delete": avoid possible race condition if file/directory deleted after call of lstat, so bypass ENOENT error code.
Thanks to Rainer Müller (aka raimue)
Diffstat (limited to 'generic')
-rw-r--r--generic/tclFCmd.c18
1 files changed, 9 insertions, 9 deletions
diff --git a/generic/tclFCmd.c b/generic/tclFCmd.c
index c52cd1e..5b2fbe1 100644
--- a/generic/tclFCmd.c
+++ b/generic/tclFCmd.c
@@ -373,14 +373,7 @@ TclFileDeleteCmd(
*/
if (Tcl_FSLstat(objv[i], &statBuf) != 0) {
- /*
- * Trying to delete a file that does not exist is not considered
- * an error, just a no-op
- */
-
- if (errno != ENOENT) {
- result = TCL_ERROR;
- }
+ result = TCL_ERROR;
} else if (S_ISDIR(statBuf.st_mode)) {
/*
* We own a reference count on errorBuffer, if it was set as a
@@ -416,9 +409,16 @@ TclFileDeleteCmd(
}
if (result != TCL_OK) {
- result = TCL_ERROR;
/*
+ * Avoid possible race condition (file/directory deleted after call
+ * of lstat), so bypass ENOENT because not an error, just a no-op
+ */
+ if (errno == ENOENT) {
+ result = TCL_OK;
+ continue;
+ }
+ /*
* It is important that we break on error, otherwise we might end
* up owning reference counts on numerous errorBuffers.
*/