]> www.infradead.org Git - users/jedix/linux-maple.git/commit
bcachefs: early return for negative values when parsing BCH_OPT_UINT
authorIntegral <integral@archlinuxcn.org>
Sun, 6 Apr 2025 14:53:28 +0000 (22:53 +0800)
committerKent Overstreet <kent.overstreet@linux.dev>
Thu, 22 May 2025 00:14:07 +0000 (20:14 -0400)
commit0e790469bf3044022cb02025abdae775c9908ca8
treef2a5f7247e9cafe5e45f19d75a0fcc5804e8b59f
parent3a2a0d08b225047ac1d2504059c45a5acf8072b8
bcachefs: early return for negative values when parsing BCH_OPT_UINT

Currently, when passing a negative integer as argument, the error
message is "too big" due to casting to an unsigned integer:

    > bcachefs format --block_size=-1 bcachefs.img
    invalid option: block_size: too big (max 65536)

When negative value in argument detected, return early before
calling bch2_opt_validate().

A new error code `BCH_ERR_option_negative` is added.

Signed-off-by: Integral <integral@archlinuxcn.org>
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
fs/bcachefs/errcode.h
fs/bcachefs/opts.c