public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Arnaud Charlet <charlet@adacore.com>
To: gcc-patches@gcc.gnu.org
Cc: Ed Schonberg <schonberg@adacore.com>
Subject: [Ada] Crash on illegal specification for a configuration file.
Date: Tue, 25 Apr 2017 09:22:00 -0000	[thread overview]
Message-ID: <20170425090107.GA66055@adacore.com> (raw)

[-- Attachment #1: Type: text/plain, Size: 578 bytes --]

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  <schonberg@adacore.com>

	* osint.adb (Find_File): Handle properly a request for a
	configuration file whose name is a directory.


[-- Attachment #2: difs --]
[-- Type: text/plain, Size: 1461 bytes --]

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;

                 reply	other threads:[~2017-04-25  9:01 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20170425090107.GA66055@adacore.com \
    --to=charlet@adacore.com \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=schonberg@adacore.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).