From: Sebastien GODARD Date: Sat, 26 May 2018 15:47:18 +0000 (+0200) Subject: sadf: SVG: Fix coredump problem when --dev option used X-Git-Tag: v11.7.4~3 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=0a14843a7420d39be1333338d0cfb21a28879973;p=sysstat sadf: SVG: Fix coredump problem when --dev option used Function svg_print_disk_stats() should allocate only the necessary number of slots when a list of devices has been entered on the command line with option "--dev=". Signed-off-by: Sebastien GODARD --- diff --git a/svg_stats.c b/svg_stats.c index b6f8994..7988941 100644 --- a/svg_stats.c +++ b/svg_stats.c @@ -2084,6 +2084,16 @@ __print_funct_t svg_print_disk_stats(struct activity *a, int curr, int action, s for (i = 0; i < a->nr[curr]; i++) { sdc = (struct stats_disk *) ((char *) a->buf[curr] + i * a->msize); + /* Get device name */ + item_name = get_sa_devname(sdc->major, sdc->minor, flags); + + if (dlst_dev_idx) { + /* A list of devices has been entered on the command line */ + if (!search_sa_dlist(st_dev_list, dlst_dev_idx, item_name)) + /* Device not found */ + continue; + } + /* Look for corresponding graph */ for (k = 0; k < svg_p->nr_max; k++) { if ((sdc->major == *(spmax + k * 9 + 8)) && @@ -2107,15 +2117,6 @@ __print_funct_t svg_print_disk_stats(struct activity *a, int curr, int action, s pos = k * 9; unregistered = outsize + pos + 8; - j = check_disk_reg(a, curr, !curr, i); - if (j < 0) { - /* This is a newly registered interface. Previous stats are zero */ - sdp = &sdpzero; - } - else { - sdp = (struct stats_disk *) ((char *) a->buf[!curr] + j * a->msize); - } - /* * If current device was marked as previously unregistered, * then set restart variable to TRUE so that the graph will be @@ -2132,6 +2133,15 @@ __print_funct_t svg_print_disk_stats(struct activity *a, int curr, int action, s *(spmin + pos + 8) = sdc->minor; } + j = check_disk_reg(a, curr, !curr, i); + if (j < 0) { + /* This is a newly registered interface. Previous stats are zero */ + sdp = &sdpzero; + } + else { + sdp = (struct stats_disk *) ((char *) a->buf[!curr] + j * a->msize); + } + /* Check for min/max values */ save_extrema(local_types_nr, (void *) sdc, (void *) sdp, itv, spmin + pos, spmax + pos, g_fields);