From owner-freebsd-bugs@FreeBSD.ORG Tue May 20 09:10:03 2008 Return-Path: Delivered-To: freebsd-bugs@hub.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id C61F11065679 for ; Tue, 20 May 2008 09:10:03 +0000 (UTC) (envelope-from gnats@FreeBSD.org) Received: from freefall.freebsd.org (freefall.freebsd.org [IPv6:2001:4f8:fff6::28]) by mx1.freebsd.org (Postfix) with ESMTP id B3B378FC2C for ; Tue, 20 May 2008 09:10:03 +0000 (UTC) (envelope-from gnats@FreeBSD.org) Received: from freefall.freebsd.org (gnats@localhost [127.0.0.1]) by freefall.freebsd.org (8.14.2/8.14.2) with ESMTP id m4K9A3Xj051727 for ; Tue, 20 May 2008 09:10:03 GMT (envelope-from gnats@freefall.freebsd.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.14.2/8.14.1/Submit) id m4K9A3VF051724; Tue, 20 May 2008 09:10:03 GMT (envelope-from gnats) Date: Tue, 20 May 2008 09:10:03 GMT Message-Id: <200805200910.m4K9A3VF051724@freefall.freebsd.org> To: freebsd-bugs@FreeBSD.org From: Stas Timokhin Cc: Subject: Re: bin/122925: sftp(1) duplicates filename when get listing directory on CDROM X-BeenThere: freebsd-bugs@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list Reply-To: Stas Timokhin List-Id: Bug reports List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 20 May 2008 09:10:03 -0000 The following reply was made to PR bin/122925; it has been noted by GNATS. From: Stas Timokhin To: Jaakko Heinonen Cc: Bruce Cran , 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 !