[Ms-nfs41-client-devel] Corrupted file name in Cygwin - does Cygwin do a silly rename if a file is open?

Cedric Blancher cedric.blancher@gmail.com
Sun Nov 24 07:19:00 GMT 2024


On Sat, 23 Nov 2024 at 20:06, Roland Mainz <roland.mainz@nrubsig.org> wrote:
>
> On Sat, Nov 23, 2024 at 2:53 PM Cedric Blancher
> <cedric.blancher@gmail.com> wrote:
> >
> > Good afternoon!
> >
> > Does Cygwin do a silly rename if a Cygwin file is open but gets
> > /bin/rm at the same time?
> >
> > What I see is that on a NFSv4.1 filesystem a
> >
> > bash -c 'touch sillytest ; ls -l ; ( command exec {n}<"sillytest" ;
> > print $n ; sleep 10) & sleep 1 ; ls -la ; rm -f sillytest ; ls -la ;
> > wait'
> >
> > will send invalid characters over the network.
> > At first I thought it's a bug in the ms-nfs41-client filesystem
> > driver, but if I replace the rm -f sillytest with a cmd /C "del
> > sillytest" the garbage filename data goes away:
> >
> > bash -c 'touch sillytest ; ls -l ; ( command exec {n}<"sillytest" ;
> > printf "fd=%d\n" $n ; sleep 10) & sleep 1 ; ls -la ; cmd /C "del
> > sillytest" ; ls -la ; wait'
> >
> > I think doing a /bin/rm on an opened file causes Cygwin to rename the
> > file, but the destination file name is corrupted or comes from
> > uninitialized memory.
>
> Please update ms-nfs-41-client to
> https://github.com/kofemann/ms-nfs41-client/commit/2ed7d65d99d134e78782c183aa39c270f7e7f07e
> (or better "HEAD"), that should reject any attempts to write/rename
> filenames which are not valid Windows characters.
> NFSv4.1 only uses UTF-8 in the protocol, so the Windows NFSv4.1 client
> side has to do a |WideCharToMultiByte(CP_UTF8, ...)|, and commit
> "2ed7d65d99d134e78782c183aa39c270f7e7f07e" enforces that it only uses
> valid UTF-8 OR returns an error.
>
> If there is any Windows application generating invalid Win32
> |wchar_t|-strings, then this should catch it and complain about it in
> the client log and return an |ERROR_INVALID_PARAMETER| to the client.

I now see errors in the NFS client log. Before that the NFS server was
returning an error, and the client acted accordingly. So seems to be
fine, except that Cygwin somehow generates a rename with an invalid
destination UTF-16 file name if someone deletes a file which is still
open.


Ced
--
Cedric Blancher <cedric.blancher@gmail.com>
[https://plus.google.com/u/0/+CedricBlancher/]
Institute Pasteur


More information about the Cygwin mailing list