Re: [PATCH] imsm: Block volume creation with empty name

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 8/10/18 8:20 AM, Roman Sobanski wrote:
> There is a possibility to create a RAID with empty name. Block it. Also
> remove trailing and leading whitespaces from given name.
> 
> Signed-off-by: Roman Sobanski <roman.sobanski@xxxxxxxxx>
> ---
>  super-intel.c | 14 +++++++++++++-
>  1 file changed, 13 insertions(+), 1 deletion(-)

Applied!

Thanks,
Jes


> diff --git a/super-intel.c b/super-intel.c
> index f011a31f..d3d256a4 100644
> --- a/super-intel.c
> +++ b/super-intel.c
> @@ -5285,10 +5285,22 @@ static int check_name(struct intel_super *super, char *name, int quiet)
>  {
>  	struct imsm_super *mpb = super->anchor;
>  	char *reason = NULL;
> +	char *start = name;
> +	size_t len = strlen(name);
>  	int i;
>  
> -	if (strlen(name) > MAX_RAID_SERIAL_LEN)
> +	if (len > 0) {
> +		while (isspace(start[len - 1]))
> +			start[--len] = 0;
> +		while (*start && isspace(*start))
> +			++start, --len;
> +		memmove(name, start, len + 1);
> +	}
> +
> +	if (len > MAX_RAID_SERIAL_LEN)
>  		reason = "must be 16 characters or less";
> +	else if (len == 0)
> +		reason = "must be a non-empty string";
>  
>  	for (i = 0; i < mpb->num_raid_devs; i++) {
>  		struct imsm_dev *dev = get_imsm_dev(super, i);
> 




[Index of Archives]     [Linux RAID Wiki]     [ATA RAID]     [Linux SCSI Target Infrastructure]     [Linux Block]     [Linux IDE]     [Linux SCSI]     [Linux Hams]     [Device Mapper]     [Device Mapper Cryptographics]     [Kernel]     [Linux Admin]     [Linux Net]     [GFS]     [RPM]     [git]     [Yosemite Forum]


  Powered by Linux