diff options
author | Zdenek Kabelac <zkabelac@redhat.com> | 2011-01-10 13:07:58 +0000 |
---|---|---|
committer | Zdenek Kabelac <zkabelac@redhat.com> | 2011-01-10 13:07:58 +0000 |
commit | 12fbaae042651eaa7ab74f0b658fbfecc90f2f87 (patch) | |
tree | 32be2bc2b06d1595499b660493d7fcf78f4cc1d8 | |
parent | 349da06cfae5033d9c9cef638b95ae5016316950 (diff) | |
download | lvm2-12fbaae042651eaa7ab74f0b658fbfecc90f2f87.tar.gz lvm2-12fbaae042651eaa7ab74f0b658fbfecc90f2f87.tar.xz lvm2-12fbaae042651eaa7ab74f0b658fbfecc90f2f87.zip |
Add default error path for get_property
Set invalid property value for error path when NULL handler is passed.
Fixes use of uninitialized prop structure as we return 'v' by value.
---
-rw-r--r-- | WHATS_NEW | 1 | ||||
-rw-r--r-- | liblvm/lvm_misc.c | 26 |
2 files changed, 12 insertions, 15 deletions
@@ -1,5 +1,6 @@ Version 2.02.80 - ==================================== + Detect NULL handle in get_property(). Fix superfluous /usr in ocf_scriptdir instalation path. Add --with-ocfdir configurable option. Add aclocal.m4 (for pkgconfig). diff --git a/liblvm/lvm_misc.c b/liblvm/lvm_misc.c index 62fef612..3bf6a043 100644 --- a/liblvm/lvm_misc.c +++ b/liblvm/lvm_misc.c @@ -52,33 +52,29 @@ struct lvm_property_value get_property(const pv_t pv, const vg_t vg, struct lvm_property_type prop; struct lvm_property_value v; + memset(&v, 0, sizeof(v)); prop.id = name; + if (pv) { - if (!pv_get_property(pv, &prop)) { - v.is_valid = 0; + if (!pv_get_property(pv, &prop)) return v; - } } else if (vg) { - if (!vg_get_property(vg, &prop)) { - v.is_valid = 0; + if (!vg_get_property(vg, &prop)) return v; - } } else if (lv) { - if (!lv_get_property(lv, &prop)) { - v.is_valid = 0; + if (!lv_get_property(lv, &prop)) return v; - } } else if (lvseg) { - if (!lvseg_get_property(lvseg, &prop)) { - v.is_valid = 0; + if (!lvseg_get_property(lvseg, &prop)) return v; - } } else if (pvseg) { - if (!pvseg_get_property(pvseg, &prop)) { - v.is_valid = 0; + if (!pvseg_get_property(pvseg, &prop)) return v; - } + } else { + log_errno(EINVAL, "Invalid NULL handle passed to library function."); + return v; } + v.is_settable = prop.is_settable; v.is_string = prop.is_string; v.is_integer = prop.is_integer; |