From 1c0b35aac933587f8ed9886b2f8435016cb391ea Mon Sep 17 00:00:00 2001 From: Arnaud Charlet Date: Tue, 31 Jul 2018 09:56:53 +0000 Subject: [PATCH] [Ada] Fix potential Constraint_Error if Library_Version is too long 2018-07-31 Arnaud Charlet gcc/ada/ * gnatlink.adb: Fix potential Constraint_Error if Library_Version is too long. From-SVN: r263107 --- gcc/ada/ChangeLog | 5 +++++ gcc/ada/gnatlink.adb | 6 ++++-- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/gcc/ada/ChangeLog b/gcc/ada/ChangeLog index 92ec7513bd5..ba9599e2980 100644 --- a/gcc/ada/ChangeLog +++ b/gcc/ada/ChangeLog @@ -1,3 +1,8 @@ +2018-07-31 Arnaud Charlet + + * gnatlink.adb: Fix potential Constraint_Error if + Library_Version is too long. + 2018-07-31 Arnaud Charlet * sem_elab.adb: Remove duplicate condition detected by CodePeer. diff --git a/gcc/ada/gnatlink.adb b/gcc/ada/gnatlink.adb index f712a7abb6c..16981b88d5c 100644 --- a/gcc/ada/gnatlink.adb +++ b/gcc/ada/gnatlink.adb @@ -1102,8 +1102,10 @@ procedure Gnatlink is -- We will be looking for the static version of the library -- as it is in the same directory as the shared version. - if Next_Line (Nlast - Library_Version'Length + 1 .. Nlast) = - Library_Version + if Nlast >= Library_Version'Length + and then Next_Line + (Nlast - Library_Version'Length + 1 .. Nlast) + = Library_Version then -- Set Last to point to last character before the -- library version. -- 2.30.2