From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 20034 invoked by alias); 23 Aug 2015 19:53:26 -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 20016 invoked by uid 89); 23 Aug 2015 19:53:25 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.5 required=5.0 tests=AWL,BAYES_00,FREEMAIL_FROM,RCVD_IN_DNSWL_LOW,SPF_PASS autolearn=ham version=3.3.2 X-Spam-User: qpsmtpd, 2 recipients X-HELO: mail-io0-f182.google.com Received: from mail-io0-f182.google.com (HELO mail-io0-f182.google.com) (209.85.223.182) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES128-GCM-SHA256 encrypted) ESMTPS; Sun, 23 Aug 2015 19:53:19 +0000 Received: by iodb91 with SMTP id b91so127972267iod.1; Sun, 23 Aug 2015 12:53:17 -0700 (PDT) MIME-Version: 1.0 X-Received: by 10.107.137.81 with SMTP id l78mr16465593iod.60.1440359597198; Sun, 23 Aug 2015 12:53:17 -0700 (PDT) Received: by 10.79.35.102 with HTTP; Sun, 23 Aug 2015 12:53:17 -0700 (PDT) In-Reply-To: References: Date: Sun, 23 Aug 2015 19:59:00 -0000 Message-ID: Subject: Re: [patch,libgfortran] Handle invalid command line in EXECUTE_COMMAND_LINE From: Janne Blomqvist To: FX Cc: gcc-patches , gfortran Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable X-SW-Source: 2015-08/txt/msg01376.txt.bz2 On Fri, Aug 14, 2015 at 10:54 AM, FX wrote: > The attached patch fixes PR 62296 (https://gcc.gnu.org/bugzilla/show_bug.= cgi?id=3D62296). The Fortran interpretation there was a bit confused (see l= inks to comp.lang.fortran thread from the PR), but the consensus is that th= e standard makes a difference between the command-line returning with nonze= ro status (which sets EXITSTAT) and the command-line not being able to exec= ute at all (which sets CMDSTAT and CMDMSG). > > The attached patch recognizes this by checking the return value of system= () for magic values 126 and 127, which are used by various combinations of = shells and libc to indicate that the shell could not be executed. The attac= hed testcase checks that. > > Bootstrapped and regtested on x86_64-apple-darwin14. > OK to commit to trunk? > > FX > > > > PS: I=E2=80=99ve also taken the opportunity to rework a bit the runtime e= rror message issued when CMDSTAT is not present, to actually include the ac= tual error condition message (that which would be CMDMSG if it were present= ) rather than a generic error message. > > Otherwise looks good, but strncat is C99, and we support targets which don't have a C99 libc (been there, done that..). Since in this case you're dealing with string literals rather than user input, it ought to be safe to just use plain strcat (or strlen+memcpy, if you prefer). Ok with that change. --=20 Janne Blomqvist