Re: [PATCH v2] libmount: Fix access to uninitialised value in mnt_optstr_locate_option

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

 



On Mon, Feb 27, 2023 at 08:00:55PM +0100, Sören Tempel wrote:
> Thanks for your patch, the changes look good to me!

Thanks.

> I have one small follow-up question though. You added the following
> sentence to the documentation for mnt_match_options():
> 
> > The alone "no" is error and all matching ends with False.
> 
> I believe this to be a good change. However, If my understanding of
> this documentation comment is correct I would have expected
> 
> 	mnt_match_options("bla", "no,,")

Good point.

> 
> to return False as well but to my surprise it actually returns True. I
> understand that this is an edge case but is that intended? Maybe the ","
> should be treated as an terminating character for the "no" as well (i.e.
> in addition to the null byte)?
> 
> diff --git a/libmount/src/optstr.c b/libmount/src/optstr.c
> index 4fbbb0859..a0056c767 100644
> --- a/libmount/src/optstr.c
> +++ b/libmount/src/optstr.c
> @@ -865,7 +865,7 @@ int mnt_match_options(const char *optstr, const char *pattern)
>  			name++, namesz--;
>  		else if ((no = (startswith(name, "no") != NULL))) {
>  			name += 2, namesz -= 2;
> -			if (!*name) {
> +			if (!*name || *name == ',') {
>  				match = 0;
>  				break;	/* alone "no" keyword is error */
>  			}
> 
> With this patch applied it also returns False for the "no,," pattern.

 Applied, thanks!

    Karel

-- 
 Karel Zak  <kzak@xxxxxxxxxx>
 http://karelzak.blogspot.com




[Index of Archives]     [Netdev]     [Ethernet Bridging]     [Linux Wireless]     [Kernel Newbies]     [Security]     [Linux for Hams]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux Admin]     [Samba]

  Powered by Linux