[1.7] rename/renameat error
Eric Blake
ebb9@byu.net
Sat Sep 26 00:03:00 GMT 2009
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
According to Christopher Faylor on 9/25/2009 9:11 AM:
>> >+ /* POSIX says mkdir("symlink-to-missing/") should create the
>> >+ directory "missing", but Linux rejects it with EEXIST. Copy
>> >+ Linux behavior for now. */
>> >+
>> >+ dlen = strlen (dir);
>> >+ if (isdirsep (dir[dlen - 1]))
>
> Couldn't this index negatively if dir is zero length?
Yep, and so could rename, where this was copied from. Fixed in the respin
below.
>
>> >+ {
>> >+ stpcpy (newbuf = tp.c_get (), dir);
>
> Since stpcpy returns a pointer to the end of the buffer couldn't we use that
> and do pointer arithmetic rather than index arithmetic?
Theoretically, a good compiler can do just as well with either. But how
does it look now?
>> >- char new_buf[strlen (newpath) + 5];
>> >+ if (isdirsep (newpath[nlen - 1]) || has_dot_last_component (newpath, false))
>
> Same observation: Couldn't newpath be zero length?
Also fixed below; actually this one is fixed by using PC_NULLEMPTY, which
guarantees newpc.error will be set to ENOENT and skip this line of code.
2009-09-25 Eric Blake <ebb9@byu.net>
* syscalls.cc (link): Delete obsolete comment. Reject directories
and missing source up front.
(rename): Use correct errno for trailing '.'. Detect empty
strings. Allow trailing slash to newpath iff oldpath is
directory.
* dir.cc (mkdir): Reject dangling symlink with trailing slash.
* fhandler_disk_file.cc (fhandler_disk_file::link): Reject
trailing slash.
* fhandler.cc (fhandler_base::link): Match Linux errno.
- --
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/
iEYEARECAAYFAkq9WkoACgkQ84KuGfSFAYBPqwCbBpmB5/wvDfq1I6gKTPGILjpe
VcMAoLyrCfwt0kHJLSLDI8nQ9nWethku
=TgSy
-----END PGP SIGNATURE-----
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: cygwin.patch25
URL: <http://cygwin.com/pipermail/cygwin-patches/attachments/20090926/54c03eae/attachment.ksh>
More information about the Cygwin-patches
mailing list