lkml.org 
[lkml]   [2019]   [Feb]   [5]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH 09/12] btrfs: change set_level() to bound the level passed in
On Tue, Feb 05, 2019 at 08:06:37PM +0100, David Sterba wrote:
> On Mon, Feb 04, 2019 at 03:20:05PM -0500, Dennis Zhou wrote:
> > -unsigned int btrfs_compress_str2level(const char *str)
> > +unsigned int btrfs_compress_str2level(unsigned int type, const char *str)
> > {
> > - if (strncmp(str, "zlib", 4) != 0)
> > + unsigned int level;
> > + int ret;
> > +
> > + if (!type)
> > return 0;
> >
> > - /* Accepted form: zlib:1 up to zlib:9 and nothing left after the number */
> > - if (str[4] == ':' && '1' <= str[5] && str[5] <= '9' && str[6] == 0)
> > - return str[5] - '0';
> > + if (str[0] == ':') {
> > + ret = kstrtouint(str + 1, 10, &level);
>
> The docs kstrtouint of say that initial + is also accepted, I'd rather
> keep the level specification strict, ie. no "zlib:+3" and no garbage
> after the number.
>
> The validation is currently missing but I think we should catch levels
> out of range during mount/remount. The fallback to default is a safety
> but wrong specification should be communicated to the user early.

Ok. To make sure I understand properly for improper level (ie "30",
"+3", "+3d") set the level to default (already done) and pr_warn saying
invalid level?

Thanks,
Dennis

\
 
 \ /
  Last update: 2019-02-05 20:33    [W:0.068 / U:1.116 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site