From: Nikolay Borisov <nborisov@suse.com>
To: Pavel Machek <pavel@ucw.cz>,
clm@fb.com, David Sterba <dsterba@suse.com>,
josef@toxicpanda.com, linux-btrfs@vger.kernel.org,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH] btrfs compression: check string length
Date: Tue, 24 Sep 2019 10:01:25 +0300 [thread overview]
Message-ID: <0755d158-c219-4d22-f6d4-cb7e5e1cb170@suse.com> (raw)
In-Reply-To: <20190924061452.GA31397@amd>
On 24.09.19 г. 9:14 ч., Pavel Machek wrote:
> AFAICT, with current code user could pass something like "lzox" and
> still get "lzo" compression. Check string lengths to prevent that.
>
> Signed-off-by: Pavel Machek <pavel@denx.de>
>
> diff --git a/fs/btrfs/compression.c b/fs/btrfs/compression.c
> index b05b361..1083ab4 100644
> --- a/fs/btrfs/compression.c
> +++ b/fs/btrfs/compression.c
> @@ -51,7 +51,7 @@ bool btrfs_compress_is_valid_type(const char *str, size_t len)
> for (i = 1; i < ARRAY_SIZE(btrfs_compress_types); i++) {
> size_t comp_len = strlen(btrfs_compress_types[i]);
>
> - if (len < comp_len)
> + if (len != comp_len)
> continue;
It's like that so that we can support compression strings such as
zlib:9. In fact the initial version was written like you suggest:
https://www.mail-archive.com/linux-btrfs@vger.kernel.org/msg88216.html
>
> if (!strncmp(btrfs_compress_types[i], str, comp_len))
>
prev parent reply other threads:[~2019-09-24 7:01 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-09-24 6:14 Pavel Machek
2019-09-24 7:01 ` Nikolay Borisov [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=0755d158-c219-4d22-f6d4-cb7e5e1cb170@suse.com \
--to=nborisov@suse.com \
--cc=clm@fb.com \
--cc=dsterba@suse.com \
--cc=josef@toxicpanda.com \
--cc=linux-btrfs@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=pavel@ucw.cz \
/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
all inboxes | Powered by JetHome®