public inbox for linux-btrfs@vger.kernel.org
 help / color / mirror / Atom feed
From: Johannes Thumshirn <jthumshirn@suse.de>
To: Naohiro Aota <Naohiro.Aota@wdc.com>
Cc: David Sterba <dsterba@suse.com>,
	Nikolay Borisov <nborisov@suse.com>,
	Linux BTRFS Mailinglist <linux-btrfs@vger.kernel.org>
Subject: Re: [PATCH] btrfs: correctly validate compression type
Date: Thu, 6 Jun 2019 10:54:52 +0200	[thread overview]
Message-ID: <20190606085452.GA4172@x250> (raw)
In-Reply-To: <SN6PR04MB5231CD8957F12BBEA8093A828C170@SN6PR04MB5231.namprd04.prod.outlook.com>

On Thu, Jun 06, 2019 at 08:43:34AM +0000, Naohiro Aota wrote:
[...]
> > +bool btrfs_compress_is_valid_type(const char *str, size_t len)
> > +{
> > +	int i;
> > +
> > +	for (i = 1; i < ARRAY_SIZE(btrfs_compress_types); i++) {
> > +		size_t comp_len = strlen(btrfs_compress_types[i]);
> > +
> > +		if (comp_len != len)
> 
> Should this be "if (comp_len > len)"?

I thought about this as well and essentiall it is 'comp_len > len' as the
strncmp() later compares up to comp_len anyways. But your're rigth it'll fail
on values like "zlib:9".

Thanks,
	Johannes
-- 
Johannes Thumshirn                            SUSE Labs Filesystems
jthumshirn@suse.de                                +49 911 74053 689
SUSE LINUX GmbH, Maxfeldstr. 5, 90409 Nürnberg
GF: Felix Imendörffer, Mary Higgins, Sri Rasiah
HRB 21284 (AG Nürnberg)
Key fingerprint = EC38 9CAB C2C4 F25D 8600 D0D0 0393 969D 2D76 0850

      reply	other threads:[~2019-06-06  8:54 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-06-06  8:01 [PATCH] btrfs: correctly validate compression type Johannes Thumshirn
2019-06-06  8:02 ` Nikolay Borisov
2019-06-06  8:43 ` Naohiro Aota
2019-06-06  8:54   ` Johannes Thumshirn [this message]

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=20190606085452.GA4172@x250 \
    --to=jthumshirn@suse.de \
    --cc=Naohiro.Aota@wdc.com \
    --cc=dsterba@suse.com \
    --cc=linux-btrfs@vger.kernel.org \
    --cc=nborisov@suse.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