From patchwork Thu Mar 27 18:17:54 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ilya Dryomov X-Patchwork-Id: 3899171 Return-Path: X-Original-To: patchwork-ceph-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id EBFF9BF540 for ; Thu, 27 Mar 2014 18:18:47 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 272F520253 for ; Thu, 27 Mar 2014 18:18:47 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 4A0CD20225 for ; Thu, 27 Mar 2014 18:18:46 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1757030AbaC0SSo (ORCPT ); Thu, 27 Mar 2014 14:18:44 -0400 Received: from mail-ee0-f48.google.com ([74.125.83.48]:36305 "EHLO mail-ee0-f48.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1756966AbaC0SSn (ORCPT ); Thu, 27 Mar 2014 14:18:43 -0400 Received: by mail-ee0-f48.google.com with SMTP id b57so3172991eek.21 for ; Thu, 27 Mar 2014 11:18:42 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references; bh=YNOPMUR4GSwA9za1YeeiuZUNJ9wQEhJGpuAMvXloC28=; b=UP7otxiNK9colB+dhGObg4Jeg1kQMUH4U0MlFRLSWEQvujHTxL98/s2EhRyBt/iWnn t05ZasJoUDbt/fx9SZfg84y8vy3sc+7HpufArvhzPPkuXn/mYRw6RMkU7L6j7rz3vdoZ RJWQTQQNXKliyfpg65/8KBwJ+DEMaTIDKEsW6yyn6KXTFjN7woprM1z0jOPVVX9V71wq R/Hy6+g/PZnN2jEDoWdRTod/Xut4qblO3VQkwOFUr0moTZklcyL9OY9KkcAyGRC58mYf 94f5e7R66jksnh3GIeFKqqYTEjgAlu/uuAPiwtI2t9aUoZkS+C7SdUY8NatUMYFk/7WM VXyA== X-Gm-Message-State: ALoCoQn8cR+j1O2vfaFVXeSjyMMp7dbMRIHk+Jg3Q/dQ+GDct+/6Rm+8zCtJXyGi1zLqoNQ4eOCn X-Received: by 10.15.31.137 with SMTP id y9mr3170762eeu.12.1395944322432; Thu, 27 Mar 2014 11:18:42 -0700 (PDT) Received: from localhost ([109.110.66.7]) by mx.google.com with ESMTPSA id x3sm5971464eep.17.2014.03.27.11.18.41 for (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Thu, 27 Mar 2014 11:18:41 -0700 (PDT) From: Ilya Dryomov To: ceph-devel@vger.kernel.org Subject: [PATCH 08/33] libceph: assert length of osdmap osd arrays Date: Thu, 27 Mar 2014 20:17:54 +0200 Message-Id: <1395944299-21970-9-git-send-email-ilya.dryomov@inktank.com> X-Mailer: git-send-email 1.7.10.4 In-Reply-To: <1395944299-21970-1-git-send-email-ilya.dryomov@inktank.com> References: <1395944299-21970-1-git-send-email-ilya.dryomov@inktank.com> Sender: ceph-devel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: ceph-devel@vger.kernel.org X-Spam-Status: No, score=-7.3 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Assert 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 Reviewed-by: Alex Elder --- net/ceph/osdmap.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/net/ceph/osdmap.c b/net/ceph/osdmap.c index ec06010657b3..19aca4d3c5dd 100644 --- a/net/ceph/osdmap.c +++ b/net/ceph/osdmap.c @@ -745,19 +745,19 @@ static int osdmap_decode(void **p, void *end, struct ceph_osdmap *map) if (err) goto bad; - /* osds */ + /* osd_state, osd_weight, osd_addrs->client_addr */ ceph_decode_need(p, end, 3*sizeof(u32) + map->max_osd*(1 + sizeof(*map->osd_weight) + sizeof(*map->osd_addr)), e_inval); - *p += 4; /* skip length field (should match max) */ + BUG_ON(ceph_decode_32(p) != map->max_osd); ceph_decode_copy(p, map->osd_state, map->max_osd); - *p += 4; /* skip length field (should match max) */ + BUG_ON(ceph_decode_32(p) != map->max_osd); for (i = 0; i < map->max_osd; i++) map->osd_weight[i] = ceph_decode_32(p); - *p += 4; /* skip length field (should match max) */ + BUG_ON(ceph_decode_32(p) != map->max_osd); ceph_decode_copy(p, map->osd_addr, map->max_osd*sizeof(*map->osd_addr)); for (i = 0; i < map->max_osd; i++) ceph_decode_addr(&map->osd_addr[i]);