From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from us-smtp-1.mimecast.com (us-smtp-1.mimecast.com [207.211.31.81]) by sourceware.org (Postfix) with ESMTP id E1F043857C47 for ; Mon, 17 Aug 2020 11:01:34 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org E1F043857C47 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-417-uXiKJNbFNqKFE6JCJNe8Kw-1; Mon, 17 Aug 2020 07:01:32 -0400 X-MC-Unique: uXiKJNbFNqKFE6JCJNe8Kw-1 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 9B28481CAFD; Mon, 17 Aug 2020 11:01:31 +0000 (UTC) Received: from blade.nx (ovpn-114-47.ams2.redhat.com [10.36.114.47]) by smtp.corp.redhat.com (Postfix) with ESMTP id 62F0C10013C2; Mon, 17 Aug 2020 11:01:31 +0000 (UTC) Received: by blade.nx (Postfix, from userid 1000) id 966B7816CCA9; Mon, 17 Aug 2020 12:01:30 +0100 (BST) Date: Mon, 17 Aug 2020 12:01:30 +0100 From: Gary Benson To: Luis Machado Cc: Tom Tromey , Luis Machado via Gdb-patches Subject: Re: [PATCH] Fix malloc allocation size sanity check Message-ID: <20200817110130.GA9383@blade.nx> References: <20200812191741.4220-1-luis.machado@linaro.org> <87pn7vhd9o.fsf@tromey.com> <05c71fb9-3e87-a964-ea63-85ca4ae30bf6@linaro.org> MIME-Version: 1.0 In-Reply-To: <05c71fb9-3e87-a964-ea63-85ca4ae30bf6@linaro.org> X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-Mimecast-Spam-Score: 0.001 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset=us-ascii Content-Disposition: inline X-Spam-Status: No, score=-8.0 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on server2.sourceware.org X-BeenThere: gdb-patches@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 17 Aug 2020 11:01:36 -0000 gdb-patches wrote: > On 8/12/20 4:31 PM, Tom Tromey wrote: > > > > > > > "Luis" == Luis Machado via Gdb-patches writes: > > > > Luis> The following patch fixes this by making the length variable a size_t. > > > > main_type::length is a ULONGEST, so maybe that would be better? > > Yeah, I guess. I'll change it. > > I noticed xzalloc takes a size_t though. We're allocating a buffer on the host, to hold a value from the target. size_t is for sizes on the host, so it's appropriate for xzalloc, and main_type::length came from the the target, so ULONGEST is appropriate there. The boundary stops things being neat :( Cheers, Gary -- Gary Benson - he / him / his Principal Software Engineer, Red Hat