From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-ej1-x62e.google.com (mail-ej1-x62e.google.com [IPv6:2a00:1450:4864:20::62e]) by sourceware.org (Postfix) with ESMTPS id 1E82E3852763 for ; Mon, 4 Jul 2022 07:50:21 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 1E82E3852763 Received: by mail-ej1-x62e.google.com with SMTP id q6so15172825eji.13 for ; Mon, 04 Jul 2022 00:50:21 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id:mime-version :content-disposition; bh=R21G8bTKd7YWPQTFyDLCPLwUhEkZMJYOnhuV0dy1PtY=; b=MZ79iOz8kjdv8QVowFekkIGdJqb1fc/rPoj7sHEKiLUBcQ+g7vkwiMoWOjMfCbywnx OXfwAaKe8TJucWUA3VrlDzEOQVvObG7GIw1Fipz4emnlZ/oHLDDPOvjfjHallVlgVIsj OT3YoWwlbhz/Jbnlnvz8Wnpj+z2Yw+Bk6oCvasFTGdm0J0lrRt8Y9F/5DTvAHgHPRuo3 fs7SXdMoRglLfpBPyRRK10tuDfdFNr2V7ozaA4IZTRHKSn3FihtIqUCnAIfa6ZkS+07v Z+d8/3CdswLdXN0YG1V4ld2d74zJHHfd1okQXb2kN8K0pTw0FskNMtkyCaqyBx8gJGYo IAKw== X-Gm-Message-State: AJIora8JlJgcFJkCe7obtd5550e5VFJhEeVB5LTilE80jgBTO4Ohqhyf Jlk7g/T4zI7g6bGLQOv3NisJB/DM1czzoA== X-Google-Smtp-Source: AGRyM1tV49lufdCjrHtUFyI5KwBSBDL/QGw4ski6EwjjfbkSGvS5Gu2XfmdfcjLa/HB/ZuE42LpcOw== X-Received: by 2002:a17:907:b09:b0:72a:8f36:e781 with SMTP id h9-20020a1709070b0900b0072a8f36e781mr14980870ejl.362.1656921019851; Mon, 04 Jul 2022 00:50:19 -0700 (PDT) Received: from adacore.com ([45.147.211.82]) by smtp.gmail.com with ESMTPSA id jl18-20020a17090775d200b006fec8e8eff6sm13963755ejc.176.2022.07.04.00.50.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 04 Jul 2022 00:50:19 -0700 (PDT) Date: Mon, 4 Jul 2022 07:50:18 +0000 From: Pierre-Marie de Rodat To: gcc-patches@gcc.gnu.org Cc: Justin Squirek Subject: [Ada] Single character argument in call to Quote_Argument raises error Message-ID: <20220704075018.GA99213@adacore.com> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="HlL+5n6rz5pIUxbD" Content-Disposition: inline X-Spam-Status: No, score=-13.2 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 04 Jul 2022 07:50:22 -0000 --HlL+5n6rz5pIUxbD Content-Type: text/plain; charset=us-ascii Content-Disposition: inline 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. --HlL+5n6rz5pIUxbD Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="patch.diff" 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 --HlL+5n6rz5pIUxbD--