Re: [PATCH v10 3/3] btrfs: create read policy sysfs attribute, pid

David Sterba
2020-10-29T16:48:52Z

On Wed, Oct 28, 2020 at 09:14:47PM +0800, Anand Jain wrote:
> +static ssize_t btrfs_read_policy_store(struct kobject *kobj,
> + struct kobj_attribute *a,
> + const char *buf, size_t len)
> +{
> + int i;
> + struct btrfs_fs_devices *fs_devices = to_fs_devs(kobj);
> +
> + for (i = 0; i < BTRFS_NR_READ_POLICY; i++) {
> + if (btrfs_strmatch(buf, btrfs_read_policy_name[i])) {

Does sysfs guarantee that the buf is nul terminated string or that it
contains a null at all? Because if not, the skip_space step of strmatch
could run out of the buffer.