From: Pierre-Marie de Rodat <derodat@adacore.com>
To: gcc-patches@gcc.gnu.org
Cc: Justin Squirek <squirek@adacore.com>
Subject: [Ada] Single character argument in call to Quote_Argument raises error
Date: Mon, 4 Jul 2022 07:50:18 +0000 [thread overview]
Message-ID: <20220704075018.GA99213@adacore.com> (raw)
[-- Attachment #1: Type: text/plain, Size: 378 bytes --]
This patch corrects an issue in the compiler whereby calling
Quote_Argument with an argument that is of size 1 may lead to a
CONSTRAINT_ERROR raised at runtime due to an undersized buffer.
Tested on x86_64-pc-linux-gnu, committed on trunk
gcc/ada/
* libgnat/s-os_lib.adb (Quote_Argument): Modify the result
buffer size calculation to handle the case where Arg'Length is
1.
[-- Attachment #2: patch.diff --]
[-- Type: text/x-diff, Size: 545 bytes --]
diff --git a/gcc/ada/libgnat/s-os_lib.adb b/gcc/ada/libgnat/s-os_lib.adb
--- a/gcc/ada/libgnat/s-os_lib.adb
+++ b/gcc/ada/libgnat/s-os_lib.adb
@@ -1940,7 +1940,7 @@ package body System.OS_Lib is
procedure Quote_Argument (Arg : in out String_Access) is
J : Positive := 1;
Quote_Needed : Boolean := False;
- Res : String (1 .. Arg'Length * 2);
+ Res : String (1 .. Arg'Length * 2 + 2);
begin
if Arg (Arg'First) /= '"' or else Arg (Arg'Last) /= '"' then
reply other threads:[~2022-07-04 7:50 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=20220704075018.GA99213@adacore.com \
--to=derodat@adacore.com \
--cc=gcc-patches@gcc.gnu.org \
--cc=squirek@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).