Date: Tue, 6 Dec 2011 13:30:12 GMT From: Jaakko Heinonen <jh@FreeBSD.org> To: freebsd-bugs@FreeBSD.org Subject: Re: kern/163076: It is not possible to read in chunks from linprocfs and procfs. Message-ID: <201112061330.pB6DUCB9086395@freefall.freebsd.org>
next in thread | raw e-mail | index | archive | help
The following reply was made to PR kern/163076; it has been noted by GNATS. From: Jaakko Heinonen <jh@FreeBSD.org> To: Poul-Henning Kamp <phk@phk.freebsd.dk> Cc: Petr Salinger <Petr.Salinger@seznam.cz>, bug-followup@FreeBSD.org Subject: Re: kern/163076: It is not possible to read in chunks from linprocfs and procfs. Date: Tue, 6 Dec 2011 15:21:36 +0200 On 2011-12-06, Poul-Henning Kamp wrote: > >Shouldn't sbuf_finish() then check s->s_error before appending the > >trailing '\0' and setting the SBUF_FINISHED flag? The problem in > >question wasn't caught earlier because sbuf_finish() happily finishes > >the buffer even if it has an error. > > I belive the code is written so that there is always reserved space > for the final '\0' > > sbuf_finish() should finish _any_ sbuf, and return zero only if > the finished buffer is fully OK. Anyway I find it inconsistent that you can successfully call sbuf_finish() and sbuf_data() but not for example sbuf_len() on an errored buffer. Thus you can "fix" the problem with the subtle change below. %%% Index: sys/fs/pseudofs/pseudofs_vnops.c =================================================================== --- sys/fs/pseudofs/pseudofs_vnops.c (revision 228153) +++ sys/fs/pseudofs/pseudofs_vnops.c (working copy) @@ -651,7 +651,7 @@ pfs_read(struct vop_read_args *va) } sbuf_finish(sb); - error = uiomove_frombuf(sbuf_data(sb), sbuf_len(sb), uio); + error = uiomove_frombuf(sbuf_data(sb), strlen(sbuf_data(sb)), uio); sbuf_delete(sb); ret: vn_lock(vn, locked | LK_RETRY); %%% -- Jaakko
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201112061330.pB6DUCB9086395>