lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <76f6f003-defb-96c8-162b-7242fe51f1ec@gmail.com>
Date: Mon, 18 Sep 2023 09:11:51 -0600
From: David Ahern <dsahern@...il.com>
To: Stephen Hemminger <stephen@...workplumber.org>, netdev@...r.kernel.org
Subject: Re: [PATCH iproute2 v2] allow overriding color option in environment

On 9/16/23 9:03 AM, Stephen Hemminger wrote:
> diff --git a/lib/color.c b/lib/color.c
> index 59976847295c..e2ffefaf75a8 100644
> --- a/lib/color.c
> +++ b/lib/color.c
> @@ -93,6 +93,32 @@ bool check_enable_color(int color, int json)
>  	return false;
>  }
>  
> +static bool match_color_value(const char *arg, int *val)
> +{
> +	if (*arg == '\0' || !strcmp(arg, "always"))

here you check for a null string

> +		*val = COLOR_OPT_ALWAYS;
> +	else if (!strcmp(arg, "auto"))
> +		*val = COLOR_OPT_AUTO;
> +	else if (!strcmp(arg, "never"))
> +		*val = COLOR_OPT_NEVER;
> +	else
> +		return false;
> +	return true;
> +}
> +
> +int default_color(void)
> +{
> +	const char *name;
> +	int val;
> +
> +	name = getenv("IPROUTE_COLORS");
> +	if (name && *name && match_color_value(name, &val))

so you can drop the `*name` check here


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ