From: Sebastien GODARD Date: Mon, 22 Feb 2016 17:49:47 +0000 (+0100) Subject: SVG: Check index in svg_colors[] array X-Git-Tag: v11.3.2~29 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=0f78d1bcf1d26d0810b5645fbefc962d4911f8e5;p=sysstat SVG: Check index in svg_colors[] array Make sure that index used to get colors from svg_colors[] array doesn't exceed array size. Signed-off-by: Sebastien GODARD --- diff --git a/svg_stats.c b/svg_stats.c index 9b63d3c..de9602c 100644 --- a/svg_stats.c +++ b/svg_stats.c @@ -45,6 +45,7 @@ unsigned int svg_colors[] = {0x00cc00, 0xff00bf, 0x00ffff, 0xff0000, 0x0000ff, 0xffbf00, 0x00ff00, 0x7030a0, 0xffffbf, 0xffff00, 0xd60093, 0x00bfbf, 0xcc3300, 0xbfbfbf, 0x666635, 0xff3300}; +#define SVG_COLORS_IDX_MASK 0x0f /* *************************************************************************** @@ -410,7 +411,7 @@ void draw_activity_graphs(struct activity *a, char *title[], char *g_title[], in printf("" "%s (%.2f, %.2f)\n", 5 + SVG_M_XSIZE + SVG_G_XSIZE, SVG_M_YSIZE + i * SVG_T_YSIZE + j * 15, - svg_colors[pos + j], g_title[pos + j], + svg_colors[(pos + j) & SVG_COLORS_IDX_MASK], g_title[pos + j], *(spmin + pos + j), *(spmax + pos + j)); } @@ -475,7 +476,8 @@ void draw_activity_graphs(struct activity *a, char *title[], char *g_title[], in printf("\n", - svg_p->graph_no, pos + j, out_p, svg_colors[pos + j], + svg_p->graph_no, pos + j, out_p, + svg_colors[(pos + j) & SVG_COLORS_IDX_MASK], xfactor, yfactor); free(out_p);