Re: [PATCH v3 08/19] libmultipath: _install_keyword cleanup

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

 



On Fri, 2018-09-21 at 18:05 -0500, Benjamin Marzinski wrote:
> _install_keyword should use VECTOR_LAST_SLOT(), which has better
> error
> checking. It should also fail if it gets a NULL pointer, instead of
> dereferencing it. Found by coverity.
> 
> Signed-off-by: Benjamin Marzinski <bmarzins@xxxxxxxxxx>

Reviewed-by: Martin Wilck <mwilck@xxxxxxxx>


> ---
>  libmultipath/parser.c | 12 ++++++++----
>  1 file changed, 8 insertions(+), 4 deletions(-)
> 
> diff --git a/libmultipath/parser.c b/libmultipath/parser.c
> index b8b7e0d..92ef7cf 100644
> --- a/libmultipath/parser.c
> +++ b/libmultipath/parser.c
> @@ -79,12 +79,16 @@ _install_keyword(vector keywords, char *string,
>  	struct keyword *keyword;
>  
>  	/* fetch last keyword */
> -	keyword = VECTOR_SLOT(keywords, VECTOR_SIZE(keywords) - 1);
> +	keyword = VECTOR_LAST_SLOT(keywords);
> +	if (!keyword)
> +		return 1;
>  
>  	/* position to last sub level */
> -	for (i = 0; i < sublevel; i++)
> -		keyword =
> -		    VECTOR_SLOT(keyword->sub, VECTOR_SIZE(keyword->sub) 
> - 1);
> +	for (i = 0; i < sublevel; i++) {
> +		keyword = VECTOR_LAST_SLOT(keyword->sub);
> +		if (!keyword)
> +			return 1;
> +	}
>  
>  	/* First sub level allocation */
>  	if (!keyword->sub)

-- 
Dr. Martin Wilck <mwilck@xxxxxxxx>, Tel. +49 (0)911 74053 2107
SUSE Linux GmbH, GF: Felix Imendörffer, Jane Smithard, Graham Norton
HRB 21284 (AG Nürnberg)


--
dm-devel mailing list
dm-devel@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/dm-devel




[Index of Archives]     [DM Crypt]     [Fedora Desktop]     [ATA RAID]     [Fedora Marketing]     [Fedora Packaging]     [Fedora SELinux]     [Yosemite Discussion]     [KDE Users]     [Fedora Docs]

  Powered by Linux