]> sourceware.org Git - lvm2.git/commitdiff
Add default error path for get_property
authorZdenek Kabelac <zkabelac@redhat.com>
Mon, 10 Jan 2011 13:07:58 +0000 (13:07 +0000)
committerZdenek Kabelac <zkabelac@redhat.com>
Mon, 10 Jan 2011 13:07:58 +0000 (13:07 +0000)
Set invalid property value for error path when NULL handler is passed.
Fixes use of uninitialized prop structure as we return 'v' by value.
---

WHATS_NEW
liblvm/lvm_misc.c

index 07839c8b5d49ebc61892ce9b026c039320553e4e..f3c357dd3abb84c2909b26af48cb65cdc3256415 100644 (file)
--- a/WHATS_NEW
+++ b/WHATS_NEW
@@ -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).
index 62fef6124425bec5c425762eb404538f382bc00a..3bf6a04373a03858d2dee1721e9b97321bfc8d45 100644 (file)
@@ -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;
This page took 0.037597 seconds and 5 git commands to generate.