Skip to content

Commit 2d88b2e

Browse files
idryomovSage Weil
authored andcommitted
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>
1 parent 3977058 commit 2d88b2e

1 file changed

Lines changed: 10 additions & 4 deletions

File tree

‎net/ceph/osdmap.c‎

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -745,19 +745,25 @@ static int osdmap_decode(void **p, void *end, struct ceph_osdmap *map)
745745
if (err)
746746
goto bad;
747747

748-
/* osds */
748+
/* osd_state, osd_weight, osd_addrs->client_addr */
749749
ceph_decode_need(p, end, 3*sizeof(u32) +
750750
map->max_osd*(1 + sizeof(*map->osd_weight) +
751751
sizeof(*map->osd_addr)), e_inval);
752752

753-
*p += 4; /* skip length field (should match max) */
753+
if (ceph_decode_32(p) != map->max_osd)
754+
goto e_inval;
755+
754756
ceph_decode_copy(p, map->osd_state, map->max_osd);
755757

756-
*p += 4; /* skip length field (should match max) */
758+
if (ceph_decode_32(p) != map->max_osd)
759+
goto e_inval;
760+
757761
for (i = 0; i < map->max_osd; i++)
758762
map->osd_weight[i] = ceph_decode_32(p);
759763

760-
*p += 4; /* skip length field (should match max) */
764+
if (ceph_decode_32(p) != map->max_osd)
765+
goto e_inval;
766+
761767
ceph_decode_copy(p, map->osd_addr, map->max_osd*sizeof(*map->osd_addr));
762768
for (i = 0; i < map->max_osd; i++)
763769
ceph_decode_addr(&map->osd_addr[i]);

0 commit comments

Comments
 (0)