From: David Sterba <dsterba@suse.cz>
To: Josef Bacik <jbacik@fb.com>
Cc: dsterba@suse.cz, Robert Marklund <robbelibobban@gmail.com>,
linux-btrfs@vger.kernel.org
Subject: Re: [PATCH] check: check so offset is not bigger then the leaf
Date: Thu, 25 Jun 2015 18:49:58 +0200 [thread overview]
Message-ID: <20150625164958.GN726@twin.jikos.cz> (raw)
In-Reply-To: <558C2B2A.1070002@fb.com>
On Thu, Jun 25, 2015 at 09:24:10AM -0700, Josef Bacik wrote:
> > +
> > + for (i = 0; i < nritems; i++) {
> > + void *tmp;
> > +
> > + tmp = btrfs_item_ptr(buf, i, void);
> > + if ((long)tmp >= BTRFS_LEAF_DATA_SIZE(root)) {
> > + ret = BTRFS_TREE_BLOCK_INVALID_OFFSETS;
> > + fprintf(stderr, "bad item pointer %lu\n",
> > + (long)tmp);
> > + goto fail;
> > + }
> > + }
>
> I'd just do
>
> if (btrfs_item_end_nr(buf, i) >= BTRFS_LEAF_DATA_SIZE(root))
>
> that way you catch problems with offset and size. Thanks,
Ah right, my check would not catch 'offset + size >= leaf data size'
if 'offset < leaf data size'. Patch welcome.
next prev parent reply other threads:[~2015-06-25 16:49 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-06-17 23:59 [PATCH] check: check so offset is not bigger then the leaf Robert Marklund
2015-06-18 16:44 ` David Sterba
2015-06-18 17:16 ` Josef Bacik
2015-06-25 16:06 ` David Sterba
2015-06-25 16:24 ` Josef Bacik
2015-06-25 16:49 ` David Sterba [this message]
2015-06-29 11:16 ` Trollkarlen Marklund
2015-07-01 13:26 ` David Sterba
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=20150625164958.GN726@twin.jikos.cz \
--to=dsterba@suse.cz \
--cc=jbacik@fb.com \
--cc=linux-btrfs@vger.kernel.org \
--cc=robbelibobban@gmail.com \
/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