diff options
author | Zdenek Kabelac <zkabelac@redhat.com> | 2020-10-19 16:43:50 +0200 |
---|---|---|
committer | Zdenek Kabelac <zkabelac@redhat.com> | 2020-10-19 16:53:19 +0200 |
commit | 3e06061d82dbcc2f464f0fdcd6610f25177bfa1f (patch) | |
tree | 7e962d47b6535dddd16cacbf3b2c6f9b1cbab601 | |
parent | a17ec7e0baa737b45900cc4f97823c95f9dd8c56 (diff) | |
download | lvm2-3e06061d82dbcc2f464f0fdcd6610f25177bfa1f.tar.gz |
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.
-rw-r--r-- | device_mapper/libdm-report.c | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/device_mapper/libdm-report.c b/device_mapper/libdm-report.c index 85d3d0f82..9279e3370 100644 --- a/device_mapper/libdm-report.c +++ b/device_mapper/libdm-report.c @@ -749,10 +749,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(" "); |