From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 54750 invoked by alias); 25 Apr 2017 09:01:10 -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 54681 invoked by uid 89); 25 Apr 2017 09:01:09 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-10.7 required=5.0 tests=AWL,BAYES_00,GIT_PATCH_2,GIT_PATCH_3,RCVD_IN_DNSWL_NONE,SPF_PASS autolearn=ham version=3.3.2 spammy= X-HELO: rock.gnat.com Received: from rock.gnat.com (HELO rock.gnat.com) (205.232.38.15) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Tue, 25 Apr 2017 09:01:06 +0000 Received: from localhost (localhost.localdomain [127.0.0.1]) by filtered-rock.gnat.com (Postfix) with ESMTP id 4F1353536; Tue, 25 Apr 2017 05:01:07 -0400 (EDT) Received: from rock.gnat.com ([127.0.0.1]) by localhost (rock.gnat.com [127.0.0.1]) (amavisd-new, port 10024) with LMTP id AjTv3mBnSgJi; Tue, 25 Apr 2017 05:01:07 -0400 (EDT) Received: from tron.gnat.com (tron.gnat.com [205.232.38.10]) by rock.gnat.com (Postfix) with ESMTP id 3DA022970B; Tue, 25 Apr 2017 05:01:07 -0400 (EDT) Received: by tron.gnat.com (Postfix, from userid 4192) id 3C66B521; Tue, 25 Apr 2017 05:01:07 -0400 (EDT) Date: Tue, 25 Apr 2017 09:22:00 -0000 From: Arnaud Charlet To: gcc-patches@gcc.gnu.org Cc: Ed Schonberg Subject: [Ada] Crash on illegal specification for a configuration file. Message-ID: <20170425090107.GA66055@adacore.com> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="J/dobhs11T7y2rNN" Content-Disposition: inline User-Agent: Mutt/1.5.23 (2014-03-12) X-SW-Source: 2017-04/txt/msg01122.txt.bz2 --J/dobhs11T7y2rNN Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-length: 578 The -gnatec switch is used to specify configuration files containing that contain configuration pragmas. With This patch the compiler rejects properly a name for a configuration file that designates a directory rather than crashing. Executing gcc -c pkg.ads -gnatec=. must yield: gnat1: cannot find configuration pragmas file . --- package pkg is private end; Tested on x86_64-pc-linux-gnu, committed on trunk 2017-04-25 Ed Schonberg * osint.adb (Find_File): Handle properly a request for a configuration file whose name is a directory. --J/dobhs11T7y2rNN Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=difs Content-length: 1461 Index: osint.adb =================================================================== --- osint.adb (revision 247135) +++ osint.adb (working copy) @@ -1189,16 +1189,25 @@ Found := N; Attr.all := Unknown_Attributes; - if T = Config and then Full_Name then - declare - Full_Path : constant String := - Normalize_Pathname (Get_Name_String (N)); - Full_Size : constant Natural := Full_Path'Length; - begin - Name_Buffer (1 .. Full_Size) := Full_Path; - Name_Len := Full_Size; - Found := Name_Find; - end; + if T = Config then + if Full_Name then + declare + Full_Path : constant String := + Normalize_Pathname (Get_Name_String (N)); + Full_Size : constant Natural := Full_Path'Length; + + begin + Name_Buffer (1 .. Full_Size) := Full_Path; + Name_Len := Full_Size; + Found := Name_Find; + end; + end if; + + -- Check that it is a file, not a directory + + if not Is_Regular_File (Get_Name_String (Found)) then + Found := No_File; + end if; end if; return; --J/dobhs11T7y2rNN--