From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 74979 invoked by alias); 26 Jun 2018 16:53:56 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Received: (qmail 74952 invoked by uid 89); 26 Jun 2018 16:53:55 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-1.9 required=5.0 tests=AWL,BAYES_00,KAM_LAZY_DOMAIN_SECURITY,SPF_HELO_PASS autolearn=no version=3.3.2 spammy=HTo:U*uweigand, agent X-HELO: mx1.redhat.com Received: from mx3-rdu2.redhat.com (HELO mx1.redhat.com) (66.187.233.73) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Tue, 26 Jun 2018 16:53:54 +0000 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 1054B4000B74; Tue, 26 Jun 2018 16:53:53 +0000 (UTC) Received: from [127.0.0.1] (ovpn04.gateway.prod.ext.ams2.redhat.com [10.39.146.4]) by smtp.corp.redhat.com (Postfix) with ESMTP id 2CE7C2026D6A; Tue, 26 Jun 2018 16:53:52 +0000 (UTC) Subject: Re: [PATCH 3/4] Use get_remote_packet_size in download_tracepoint To: Pedro Franco de Carvalho , Ulrich Weigand References: <20180625103720.2F6DAD801CC@oc3748833570.ibm.com> <878t72mvxo.fsf@linux.vnet.ibm.com> Cc: gdb-patches@sourceware.org From: Pedro Alves Message-ID: <925c0f76-f54c-0f7a-49a1-46ea365dc84a@redhat.com> Date: Tue, 26 Jun 2018 16:53:00 -0000 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.8.0 MIME-Version: 1.0 In-Reply-To: <878t72mvxo.fsf@linux.vnet.ibm.com> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-SW-Source: 2018-06/txt/msg00619.txt.bz2 On 06/25/2018 09:51 PM, Pedro Franco de Carvalho wrote: > Ulrich Weigand writes: > >> You know from the beginning that the agent expression will take >> (2 * aexpr->len) bytes, so it should be OK to only check this >> once, ahead of time. In fact, sending a partial agent expression >> seems to be worse than sending none, so if the agent expression >> is too long, I think it should be just omitted (and the user >> warned). > > I don't think a partial agent expression would be sent in this case, > since this is before the first putpkt is called in the function. But I > can still issue the warning and ignore the condition expression instead > of failing on the assertion. Otherwise I can check the size once and > call a gdb_assert if its too small, like the rest of the function. Which > is better? I'm not sure I understand the details or the suggestions below (the patches don't seem to be meant to apply on top of current master, but they're using buf.data()), but I'd just like to point out that ideally GDB should not gdb_assert or abort on user input or remote stub limitations (small remote packet size), since neither are a GDB bug. > > Would something like one of the two alternative below be ok for checking > the size only once? > > The second one looks complicated, but my goal was to avoid overflows in > 2 * aexpr->len, since that length ultimately comes from the condition > expression the user supplies. > > I am also assuming throughout this function that size_t and > gdb::char_vector::size_type are compatible (since buf.size () returns > the latter and xsnprintf takes a size_t). Is this ok? It is. Thanks, Pedro Alves