diff options
author | Stijn Tintel <stijn@linux-ipv6.be> | 2021-05-13 23:08:47 +0300 |
---|---|---|
committer | Kent Overstreet <kent.overstreet@linux.dev> | 2023-10-22 17:09:03 -0400 |
commit | ffcf9ec78c133fb85ff13d8119ff404e11820834 (patch) | |
tree | 1a6a0d2bd8278b7a1b8f4c37c9b63d5aa48675c6 /fs/bcachefs/fs.c | |
parent | 909004d2f9f8d56997010eac3ae975e214ff9d0f (diff) |
bcachefs: avoid out-of-bounds in split_devs
Calling mount with an empty source string causes an out-of-bounds error
in split_devs. Check the length of the source string to avoid this.
Signed-off-by: Stijn Tintel <stijn@linux-ipv6.be>
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
Diffstat (limited to 'fs/bcachefs/fs.c')
-rw-r--r-- | fs/bcachefs/fs.c | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/fs/bcachefs/fs.c b/fs/bcachefs/fs.c index b00f35201132..5eef67358cfb 100644 --- a/fs/bcachefs/fs.c +++ b/fs/bcachefs/fs.c @@ -32,6 +32,7 @@ #include <linux/random.h> #include <linux/seq_file.h> #include <linux/statfs.h> +#include <linux/string.h> #include <linux/xattr.h> static struct kmem_cache *bch2_inode_cache; @@ -1324,6 +1325,9 @@ static char **split_devs(const char *_dev_name, unsigned *nr) char *dev_name = NULL, **devs = NULL, *s; size_t i, nr_devs = 0; + if (strlen(_dev_name) == 0) + return NULL; + dev_name = kstrdup(_dev_name, GFP_KERNEL); if (!dev_name) return NULL; |