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]
Date:   Wed, 11 Oct 2017 10:53:52 -0700
From:   Stephen Hemminger <stephen@...workplumber.org>
To:     Petr Vorel <petr.vorel@...il.com>
Cc:     netdev@...r.kernel.org, Julien Fortin <julien@...ulusnetworks.com>
Subject: Re: [PATCH iproute2 1/1] color: Fix ip segfault in color_fprintf()
 when using --color switch

On Sun,  8 Oct 2017 16:38:47 +0200
Petr Vorel <petr.vorel@...il.com> wrote:

> diff --git a/include/json_print.h b/include/json_print.h
> index b6ce1f9f..2f3f07c8 100644
> --- a/include/json_print.h
> +++ b/include/json_print.h
> @@ -53,7 +53,7 @@ void close_json_array(enum output_type type, const char *delim);
>  					     const char *fmt,		\
>  					     type value)		\
>  	{								\
> -		print_color_##type_name(t, -1, key, fmt, value);	\
> +		print_color_##type_name(t, 0, key, fmt, value);	\
>  	}
>  _PRINT_FUNC(int, int);
>  _PRINT_FUNC(bool, bool);
> diff --git a/lib/color.c b/lib/color.c
> index 79d5e289..e597798f 100644
> --- a/lib/color.c
> +++ b/lib/color.c
> @@ -110,7 +110,7 @@ int color_fprintf(FILE *fp, enum color_attr attr, const char *fmt, ...)
>  	}
>  
>  	ret += fprintf(fp, "%s",
> -		       color_codes[attr_colors[is_dark_bg ? attr + 8 : attr]]);
> +		       color_codes[attr_colors[is_dark_bg ? attr + 6 : attr - 1]]);

Magic offsets (8 and -1) are error prone. Can this be changed to an enum value from colors?

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ