[gcc r15-1142] ada: Fix incorrect lower bound presumption in gnatlink

Marc Poulhi?s dkm@gcc.gnu.org
Mon Jun 10 09:07:59 GMT 2024


https://gcc.gnu.org/g:eb822805b51a1fa5b514a04a6e66556e3dcd3484

commit r15-1142-geb822805b51a1fa5b514a04a6e66556e3dcd3484
Author: Ronan Desplanques <desplanques@adacore.com>
Date:   Fri Apr 12 16:45:08 2024 +0200

    ada: Fix incorrect lower bound presumption in gnatlink
    
    This patch fixes a subprogram in gnatlink that incorrectly assumed
    that the strings it is passed as arguments all have a lower bound of
    1.
    
    gcc/ada/
    
            * gnatlink.adb (Check_File_Name): Fix incorrect assumption.

Diff:
---
 gcc/ada/gnatlink.adb | 17 ++++++++---------
 1 file changed, 8 insertions(+), 9 deletions(-)

diff --git a/gcc/ada/gnatlink.adb b/gcc/ada/gnatlink.adb
index d00fd9e5af7..1455412ef93 100644
--- a/gcc/ada/gnatlink.adb
+++ b/gcc/ada/gnatlink.adb
@@ -42,6 +42,7 @@ with Types;
 
 with Ada.Command_Line; use Ada.Command_Line;
 with Ada.Exceptions;   use Ada.Exceptions;
+with Ada.Strings.Fixed;
 
 with System.OS_Lib; use System.OS_Lib;
 with System.CRTL;
@@ -1697,15 +1698,13 @@ begin
 
       procedure Check_File_Name (S : String) is
       begin
-         for J in 1 .. FN'Length - (S'Length - 1) loop
-            if FN (J .. J + (S'Length - 1)) = S then
-               Error_Msg
-                 ("warning: executable file name """ & Output_File_Name.all
-                  & """ contains substring """ & S & '"');
-               Error_Msg
-                 ("admin privileges may be required to run this file");
-            end if;
-         end loop;
+         if Ada.Strings.Fixed.Index (FN, S) /= 0 then
+            Error_Msg
+              ("warning: executable file name """ & Output_File_Name.all
+               & """ contains substring """ & S & '"');
+            Error_Msg
+              ("admin privileges may be required to run this file");
+         end if;
       end Check_File_Name;
 
    --  Start of processing for Bad_File_Names_On_Windows


More information about the Gcc-cvs mailing list