This is the mail archive of the
cygwin-patches
mailing list for the Cygwin project.
Re: fd leak in utimensat
- From: Eric Blake <ebb9 at byu dot net>
- To: cygwin-patches at cygwin dot com
- Date: Wed, 07 Oct 2009 21:17:38 -0600
- Subject: Re: fd leak in utimensat
- References: <4ACD56AF.7080905@byu.net>
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
According to Eric Blake on 10/7/2009 9:04 PM:
> I haven't spent time trying to locate where the leak is happening, but
> process explorer confirms that this STC leaves a handle open to the file,
> preventing further re-creation of a new file by the same name.
Found it. OK to apply? In case it wasn't obvious, the leak only happens
on invalid timestamps; this was from a gnulib test validating that
1000000000 is rejected with EINVAL.
2009-10-08 Eric Blake <ebb9@byu.net>
* fhandler_disk_file.cc (utimens_fs): Plug leak for EINVAL.
- --
Don't work too hard, make some time for fun as well!
Eric Blake ebb9@byu.net
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (Cygwin)
Comment: Public key at home.comcast.net/~ericblake/eblake.gpg
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/
iEYEARECAAYFAkrNWc8ACgkQ84KuGfSFAYAnBgCfQqJPnnxb6sustsi4rISH35km
CCsAoJpr9V8YcWPn7ijsQzPmeuM9Sl2g
=Q+ks
-----END PGP SIGNATURE-----
diff --git a/winsup/cygwin/fhandler_disk_file.cc b/winsup/cygwin/fhandler_disk_file.cc
index 99bbf8b..1e6a781 100644
--- a/winsup/cygwin/fhandler_disk_file.cc
+++ b/winsup/cygwin/fhandler_disk_file.cc
@@ -1310,6 +1310,8 @@ fhandler_base::utimens_fs (const struct timespec *tvp)
if ((tvp[0].tv_nsec < UTIME_NOW || tvp[0].tv_nsec > 999999999L)
|| (tvp[1].tv_nsec < UTIME_NOW || tvp[1].tv_nsec > 999999999L))
{
+ if (closeit)
+ close_fs ();
set_errno (EINVAL);
return -1;
}