Date: Tue, 20 May 2008 09:10:03 GMT From: Stas Timokhin <stast@bsdportal.ru> To: freebsd-bugs@FreeBSD.org Subject: Re: bin/122925: sftp(1) duplicates filename when get listing directory on CDROM Message-ID: <200805200910.m4K9A3VF051724@freefall.freebsd.org>
next in thread | raw e-mail | index | archive | help
The following reply was made to PR bin/122925; it has been noted by GNATS.
From: Stas Timokhin <stast@bsdportal.ru>
To: Jaakko Heinonen <jh@saunalahti.fi>
Cc: Bruce Cran <bruce@cran.org.uk>,
bug-followup@freebsd.org
Subject: Re: bin/122925: sftp(1) duplicates filename when get listing directory on CDROM
Date: Tue, 20 May 2008 15:44:15 +0700
=F7 =D3=CF=CF=C2=DD=C5=CE=C9=C9 =CF=D4 Tuesday 20 May 2008 14:48:33 Jaakko =
Heinonen =CE=C1=D0=C9=D3=C1=CC(=C1):
> On 2008-05-18, Bruce Cran wrote:
> > This is occurring because sftp-server expects readdir(3) to return NULL
> > for a given DIR* twice in a row after all the files have been retrieve=
d.
> > It seems that under certain conditions that isn't true.
>
> Thanks for the test case.
>
> The problem seems to lie in cd9660_readdir()
> (src/sys/fs/cd9660/cd9660_vnops.c). The problem is that if we have
> reached end of file (directory) and enter again to cd9660_readdir()
> the idp->uio_off variable is not initialized correctly. In the end of
> the function the file offset is set to idp->uio_off. So this basically
> means that the file offset changes to a random value. This causes
> effects such readdir(3) starting again at some position or g_vfs_done()
> errors when data is attempted to read from bogus offset.
>
> I believe that this patch fixes the problem:
>
> Index: cd9660_vnops.c
> =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
> RCS file: /home/ncvs/src/sys/fs/cd9660/cd9660_vnops.c,v
> retrieving revision 1.113
> diff -p -u -r1.113 cd9660_vnops.c
> --- cd9660_vnops.c 15 Feb 2007 22:08:34 -0000 1.113
> +++ cd9660_vnops.c 20 May 2008 06:45:20 -0000
> @@ -495,6 +495,7 @@ cd9660_readdir(ap)
> }
> idp->eofflag =3D 1;
> idp->curroff =3D uio->uio_offset;
> + idp->uio_off =3D uio->uio_offset;
>
> if ((entryoffsetinblock =3D idp->curroff & bmask) &&
> (error =3D cd9660_blkatoff(vdp, (off_t)idp->curroff, NULL, &bp))) {
>
> Could you please test the patch?
Yes, i done this test. Everything looks good, thanks !
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200805200910.m4K9A3VF051724>
