public inbox for linux-xfs@vger.kernel.org
 help / color / mirror / Atom feed
From: "Darrick J. Wong" <darrick.wong@oracle.com>
To: Eric Sandeen <sandeen@sandeen.net>
Cc: sandeen@redhat.com, linux-xfs@vger.kernel.org
Subject: Re: [PATCH 1/4] xfs_db: don't print arrays off the end of a buffer
Date: Wed, 26 Apr 2017 10:45:10 -0700	[thread overview]
Message-ID: <20170426174510.GO5205@birch.djwong.org> (raw)
In-Reply-To: <a7b683c8-54a1-a12b-5f49-35fc743b1d73@sandeen.net>

On Wed, Apr 26, 2017 at 12:12:38PM -0500, Eric Sandeen wrote:
> On 4/10/17 5:47 PM, Darrick J. Wong wrote:
> > From: Darrick J. Wong <darrick.wong@oracle.com>
> > 
> > Before printing an array, clamp the array count against the size of the
> > buffer so that we don't print random heap contents.
> > 
> > Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
> > ---
> >  db/print.c |   11 +++++++++++
> >  1 file changed, 11 insertions(+)
> > 
> > 
> > diff --git a/db/print.c b/db/print.c
> > index e31372f..0caad8f 100644
> > --- a/db/print.c
> > +++ b/db/print.c
> > @@ -144,6 +144,17 @@ print_flist_1(
> >  			if (fl->flags & FL_OKHIGH)
> >  				count = min(count, fl->high - low + 1);
> >  			if (fa->prfunc) {
> > +				int	fsz;
> > +				int	bitlen;
> > +
> > +				/* Don't read an array off the end of the buffer */
> > +				fsz = fsize(f, iocur_top->data, parentoff, 0);
> > +				bitlen = iocur_top->len * NBBY;
> > +				if ((f->flags & FLD_ARRAY) &&
> > +				    fl->offset + (count * fsz) > bitlen) {
> > +					count = (bitlen - fl->offset) / fsz;
> > +				}
> > +
> >  				neednl = fa->prfunc(iocur_top->data, fl->offset,
> >  					count, fa->fmtstr,
> >  					fsize(f, iocur_top->data, parentoff, 0),
> 
> can we just re-use fsz here in the prfunc call?

Yeah, we could reuse it.

--D

> 
> Otherwise seems fine, and I could do that on commit.
> 
> Reviewed-by: Eric Sandeen <sandeen@redhat.com>
> 
> > 
> > --
> > To unsubscribe from this list: send the line "unsubscribe linux-xfs" in
> > the body of a message to majordomo@vger.kernel.org
> > More majordomo info at  http://vger.kernel.org/majordomo-info.html
> > 

  reply	other threads:[~2017-04-26 17:45 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-04-10 22:47 [PATCH v2 0/4] xfs_db misc. btree dumping improvements Darrick J. Wong
2017-04-10 22:47 ` [PATCH 1/4] xfs_db: don't print arrays off the end of a buffer Darrick J. Wong
2017-04-26 17:12   ` Eric Sandeen
2017-04-26 17:45     ` Darrick J. Wong [this message]
2017-04-10 22:47 ` [PATCH 2/4] xfs_db: use iocursor type to guess btree geometry if bad magic Darrick J. Wong
2017-04-11  0:03   ` Dave Chinner
2017-04-11  0:19     ` Darrick J. Wong
2017-04-11  0:20   ` [PATCH v2 " Darrick J. Wong
2017-04-26 17:48     ` Eric Sandeen
2017-04-26 18:25       ` Darrick J. Wong
2017-04-26 18:41         ` Eric Sandeen
2017-04-26 18:43           ` Darrick J. Wong
2017-04-26 18:47     ` [PATCH v3 " Eric Sandeen
2017-04-26 19:11       ` Darrick J. Wong
2017-04-10 22:47 ` [PATCH 3/4] xfs_db: complain about dir/attr blocks with bad magics Darrick J. Wong
2017-04-11 21:42   ` Darrick J. Wong
2017-04-10 22:48 ` [PATCH 4/4] xfs_db: dump metadata btrees via 'btdump' Darrick J. Wong
2017-04-26 19:50   ` Eric Sandeen
2017-04-26 20:27     ` Darrick J. Wong
2017-04-26 20:36   ` [PATCH v2 " Darrick J. Wong
2017-04-26 21:35     ` Eric Sandeen
  -- strict thread matches above, loose matches on Subject: below --
2017-04-08  3:03 [RFC PATCH v1 0/4] xfs_db misc. btree dumping improvements Darrick J. Wong
2017-04-08  3:03 ` [PATCH 1/4] xfs_db: don't print arrays off the end of a buffer Darrick J. Wong

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20170426174510.GO5205@birch.djwong.org \
    --to=darrick.wong@oracle.com \
    --cc=linux-xfs@vger.kernel.org \
    --cc=sandeen@redhat.com \
    --cc=sandeen@sandeen.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox