diff options
author | Ilya Dryomov <ilya.dryomov@inktank.com> | 2014-03-13 10:36:14 -0400 |
---|---|---|
committer | Sage Weil <sage@inktank.com> | 2014-04-05 00:07:41 -0400 |
commit | 2d88b2e0819e0401ebb195e9fa20fab4be1965c8 (patch) | |
tree | 2158da23ebd745e0b58f477ca1400f1934da27c6 | |
parent | 3977058c468b872c6bc5e5273bf911d791848643 (diff) |
libceph: check length of osdmap osd arrays
Check length of osd_state, osd_weight and osd_addr arrays. They
should all have exactly max_osd elements after the call to
osdmap_set_max_osd().
Signed-off-by: Ilya Dryomov <ilya.dryomov@inktank.com>
Reviewed-by: Alex Elder <elder@linaro.org>
-rw-r--r-- | net/ceph/osdmap.c | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/net/ceph/osdmap.c b/net/ceph/osdmap.c index ec06010657b3..c39ac624ccc3 100644 --- a/net/ceph/osdmap.c +++ b/net/ceph/osdmap.c | |||
@@ -745,19 +745,25 @@ static int osdmap_decode(void **p, void *end, struct ceph_osdmap *map) | |||
745 | if (err) | 745 | if (err) |
746 | goto bad; | 746 | goto bad; |
747 | 747 | ||
748 | /* osds */ | 748 | /* osd_state, osd_weight, osd_addrs->client_addr */ |
749 | ceph_decode_need(p, end, 3*sizeof(u32) + | 749 | ceph_decode_need(p, end, 3*sizeof(u32) + |
750 | map->max_osd*(1 + sizeof(*map->osd_weight) + | 750 | map->max_osd*(1 + sizeof(*map->osd_weight) + |
751 | sizeof(*map->osd_addr)), e_inval); | 751 | sizeof(*map->osd_addr)), e_inval); |
752 | 752 | ||
753 | *p += 4; /* skip length field (should match max) */ | 753 | if (ceph_decode_32(p) != map->max_osd) |
754 | goto e_inval; | ||
755 | |||
754 | ceph_decode_copy(p, map->osd_state, map->max_osd); | 756 | ceph_decode_copy(p, map->osd_state, map->max_osd); |
755 | 757 | ||
756 | *p += 4; /* skip length field (should match max) */ | 758 | if (ceph_decode_32(p) != map->max_osd) |
759 | goto e_inval; | ||
760 | |||
757 | for (i = 0; i < map->max_osd; i++) | 761 | for (i = 0; i < map->max_osd; i++) |
758 | map->osd_weight[i] = ceph_decode_32(p); | 762 | map->osd_weight[i] = ceph_decode_32(p); |
759 | 763 | ||
760 | *p += 4; /* skip length field (should match max) */ | 764 | if (ceph_decode_32(p) != map->max_osd) |
765 | goto e_inval; | ||
766 | |||
761 | ceph_decode_copy(p, map->osd_addr, map->max_osd*sizeof(*map->osd_addr)); | 767 | ceph_decode_copy(p, map->osd_addr, map->max_osd*sizeof(*map->osd_addr)); |
762 | for (i = 0; i < map->max_osd; i++) | 768 | for (i = 0; i < map->max_osd; i++) |
763 | ceph_decode_addr(&map->osd_addr[i]); | 769 | ceph_decode_addr(&map->osd_addr[i]); |