From: Zdenek Kabelac Date: Thu, 1 Nov 2018 14:33:34 +0000 (+0100) Subject: cov: split check for type assignment X-Git-Tag: v2_03_03~384 X-Git-Url: https://sourceware.org/git/?a=commitdiff_plain;h=79879bd201d4156312bb03fc0b7228ce34a3bf38;p=lvm2.git cov: split check for type assignment Check that type is always defined, if not make it explicit internal error (although logged as debug - so catched only with proper lvm.conf setting). This ensures later type being NULL can't be dereferenced with coredump. --- diff --git a/libdm/libdm-report.c b/libdm/libdm-report.c index a44701704..b0c89ab61 100644 --- a/libdm/libdm-report.c +++ b/libdm/libdm-report.c @@ -748,10 +748,11 @@ static void _display_fields_more(struct dm_report *rh, id_len = strlen(type->prefix) + 3; for (f = 0; fields[f].report_fn; f++) { - if ((type = _find_type(rh, fields[f].type)) && type->desc) - desc = type->desc; - else - desc = " "; + if (!(type = _find_type(rh, fields[f].type))) { + log_debug(INTERNAL_ERROR "Field type undefined."); + continue; + } + desc = (type->desc) ? : " "; if (desc != last_desc) { if (*last_desc) log_warn(" ");