From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 119719 invoked by alias); 14 Oct 2016 11:10:53 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Received: (qmail 119681 invoked by uid 89); 14 Oct 2016 11:10:52 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.9 required=5.0 tests=BAYES_00,SPF_PASS autolearn=ham version=3.3.2 spammy=bonus X-HELO: mx2.suse.de Received: from mx2.suse.de (HELO mx2.suse.de) (195.135.220.15) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Fri, 14 Oct 2016 11:10:42 +0000 Received: from relay2.suse.de (charybdis-ext.suse.de [195.135.220.254]) by mx2.suse.de (Postfix) with ESMTP id 5E2A3AC02; Fri, 14 Oct 2016 11:10:39 +0000 (UTC) Subject: Re: [PATCH] Check \0-termination of string in c_getstr (simplified version) To: Richard Biener References: <678ff58e-4aa3-6145-f56b-780bf618338c@suse.cz> <1db7cd13-d403-9a6c-811a-bba82a35ef37@suse.cz> <9ab67f18-42a3-d66e-6777-b066f6d9af76@suse.cz> Cc: GCC Patches From: =?UTF-8?Q?Martin_Li=c5=a1ka?= Message-ID: Date: Fri, 14 Oct 2016 11:10:00 -0000 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.4.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-IsSubscribed: yes X-SW-Source: 2016-10/txt/msg01132.txt.bz2 On 10/14/2016 11:38 AM, Richard Biener wrote: > On Thu, Oct 13, 2016 at 5:23 PM, Martin Liška wrote: >> Hello. >> >> After receiving feedback from Richi and Wilco Dijkstra, I decided to fully not >> support not null-terminated strings. It brings more complications and the code has started >> to be overengineered. Thus c_getstr accepts only such strings and as a bonus it returns >> length of a string. >> >> Patch can bootstrap on ppc64le-redhat-linux and survives regression tests. >> >> Ready to be installed? > > + /* Support only properly null-terminated strings. */ > + if (string_length == 0 > + || string[string_length - 1] != '\0' > + || offset > string_length) > > shouldn't this be offset >= string_length? Yes, it should be that, installed as r241152. Thanks, Martin > > Ok with that change. > > Thanks, > Richard. > >> Martin