From patchwork Mon Jul 4 07:50:18 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pierre-Marie de Rodat X-Patchwork-Id: 1651827 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.a=rsa-sha256 header.s=default header.b=x5LYL8Ue; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=2620:52:3:1:0:246e:9693:128c; helo=sourceware.org; envelope-from=gcc-patches-bounces+incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Received: from sourceware.org (server2.sourceware.org [IPv6:2620:52:3:1:0:246e:9693:128c]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4Lbyhh0QBlz9s5V for ; Mon, 4 Jul 2022 17:52:52 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id CED63380DBDD for ; Mon, 4 Jul 2022 07:52:49 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org CED63380DBDD DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1656921169; bh=R21G8bTKd7YWPQTFyDLCPLwUhEkZMJYOnhuV0dy1PtY=; h=Date:To:Subject:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:Cc:From; b=x5LYL8UeFHZHlVepXfm6XvMwvWlU5ql3Zx5LPeVT6xrbESvd8QeN5huqWIOMMkAae W4bVzf9xLRBxoNy0osaMmoRID8hDWevGf/t2bmjuMpTVathP5cxXCPKl4pEFYvatDp 2ATl90QO3mJQQ5JxqQXpx4y2fkUqp411hxlYTyP4= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org 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 To: gcc-patches@gcc.gnu.org Subject: [Ada] Single character argument in call to Quote_Argument raises error Message-ID: <20220704075018.GA99213@adacore.com> MIME-Version: 1.0 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-Patchwork-Original-From: Pierre-Marie de Rodat via Gcc-patches From: Pierre-Marie de Rodat Reply-To: Pierre-Marie de Rodat Cc: Justin Squirek Errors-To: gcc-patches-bounces+incoming=patchwork.ozlabs.org@gcc.gnu.org Sender: "Gcc-patches" 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. 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