From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-pj1-x1033.google.com (mail-pj1-x1033.google.com [IPv6:2607:f8b0:4864:20::1033]) by sourceware.org (Postfix) with ESMTPS id 85C513858413 for ; Mon, 20 Mar 2023 17:03:16 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 85C513858413 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=gmail.com Received: by mail-pj1-x1033.google.com with SMTP id p3-20020a17090a74c300b0023f69bc7a68so8634182pjl.4 for ; Mon, 20 Mar 2023 10:03:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; t=1679331795; h=content-transfer-encoding:mime-version:message-id:date:subject:to :from:from:to:cc:subject:date:message-id:reply-to; bh=yKZKhHkyfkGz337HSpjDvc7xlDyrnyHSWfxo5FUBtbI=; b=GAz6PuGy4upNLfcxfEGo4BPgsm9JK/uO9gQ06Ds29OwUKmGDqnOmaf0Mo0l9DB8Zj4 8imFP3JSL3u3DLTX5Ye4MQw0a9hT/FDBMLOkslSbzxwNqMExbVx6rHsStVoZXDaRCou5 lDWBtumj5PH8Gjc2vjGbK7oQ7zfcuk7gbyIdR2a39QP6ExXZNzUwDHqGwlcpGKMXOjRZ 14mniQ8mm+HWMnciIYhmu5GlxVThx4ROXOhn84KbF5rj/xtnOXp/UY9LEpg0JMsR12+B DbaOLA2X8lrPYIV/uFSS+MfXr4cookW9PDcSssPpkp8+zhv+gK4Bq6zFvGVRXBw0+qtf 8sIg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1679331795; h=content-transfer-encoding:mime-version:message-id:date:subject:to :from:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=yKZKhHkyfkGz337HSpjDvc7xlDyrnyHSWfxo5FUBtbI=; b=2KOox2PRVAV9z7ffcKtBqwHqK+KKU2/lJVbFs+AKhoD3ZVFZNsTHCE++Y+YUwzC42j iy4jcXiEnBQFOBr4cGSVxr3WuGQEpfdK6bqYOiOVAxs/MUyIpmUcd3MLjbQGHvNtI+o2 Zpswe5Zb9u+hunKvLBG7Rq19tmrU8+3J0m2P2AK4qWishO911SjM9U0+CA/fGRsRWIwH tbuUtbIFDiv51Eeqn+J8abDGWR2633T5Uui9Vh8a7MwCBEAiIFHBptfVVhQxO2fWsvda kn5K0ehUe5NRdraP2SKJ4JC7OXi0rcJ8ywuBZhvHSJ080mS/r/gyMwI/tNHPQWl8Tb9X QCXQ== X-Gm-Message-State: AO0yUKWS7uzwD+ssefPb6eQtcJtXKLpp2UL5qZUs9NN5Rc3UGalBPW7o /9x/bMxK6R5AdC7mbvVijfS77ZUPrxs= X-Google-Smtp-Source: AK7set8ZjZg4zBSicOEvcns9/O98vO64FIQMl7fpib49Q6gcL67QpocIU/ga/OBv4cDYes9fw2G8Cg== X-Received: by 2002:a17:902:f10b:b0:1a0:7678:5e16 with SMTP id e11-20020a170902f10b00b001a076785e16mr13918857plb.67.1679331794962; Mon, 20 Mar 2023 10:03:14 -0700 (PDT) Received: from gnu-cfl-3.localdomain ([172.59.161.113]) by smtp.gmail.com with ESMTPSA id y17-20020a170902b49100b0019f114570b0sm6085850plr.152.2023.03.20.10.03.14 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 20 Mar 2023 10:03:14 -0700 (PDT) Received: from gnu-cfl-3.. (localhost [IPv6:::1]) by gnu-cfl-3.localdomain (Postfix) with ESMTP id 68E7A740067 for ; Mon, 20 Mar 2023 10:03:13 -0700 (PDT) From: "H.J. Lu" To: binutils@sourceware.org Subject: [PATCH] x86: Check unbalanced braces in memory reference Date: Mon, 20 Mar 2023 10:03:13 -0700 Message-Id: <20230320170313.354203-1-hjl.tools@gmail.com> X-Mailer: git-send-email 2.39.2 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-3025.6 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM,GIT_PATCH_0,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS,TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: Check unbalanced braces in memory reference to avoid assembler crash caused by commit e87fb6a6d0cdfc0e9c471b7825c20c238c2cf506 Author: Jan Beulich Date: Wed Oct 5 09:16:24 2022 +0200 x86/gas: support quoted address scale factor in AT&T syntax PR gas/30248 * config/tc-i386.c (i386_att_operand): Check unbalanced braces in memory reference. * testsuite/gas/i386/i386.exp: Run pr30248. * testsuite/gas/i386/pr30248.d: New file. * testsuite/gas/i386/pr30248.err: Likewise. * testsuite/gas/i386/pr30248.s: Likewise. --- gas/config/tc-i386.c | 6 +++++- gas/testsuite/gas/i386/i386.exp | 1 + gas/testsuite/gas/i386/pr30248.d | 2 ++ gas/testsuite/gas/i386/pr30248.err | 5 +++++ gas/testsuite/gas/i386/pr30248.s | 2 ++ 5 files changed, 15 insertions(+), 1 deletion(-) create mode 100644 gas/testsuite/gas/i386/pr30248.d create mode 100644 gas/testsuite/gas/i386/pr30248.err create mode 100644 gas/testsuite/gas/i386/pr30248.s diff --git a/gas/config/tc-i386.c b/gas/config/tc-i386.c index ed8329f25d8..44efad73e5d 100644 --- a/gas/config/tc-i386.c +++ b/gas/config/tc-i386.c @@ -11613,7 +11613,11 @@ i386_att_operand (char *operand_string) temp_string = base_string; /* Skip past '(' and whitespace. */ - gas_assert (*base_string == '('); + if (*base_string != '(') + { + as_bad (_("unbalanced braces")); + return 0; + } ++base_string; if (is_space_char (*base_string)) ++base_string; diff --git a/gas/testsuite/gas/i386/i386.exp b/gas/testsuite/gas/i386/i386.exp index 590cd783efe..4d2150f9c68 100644 --- a/gas/testsuite/gas/i386/i386.exp +++ b/gas/testsuite/gas/i386/i386.exp @@ -752,6 +752,7 @@ run_dump_test pr19498 run_list_test "nop-bad-1" "" run_list_test "unspec" "" run_dump_test "fp" +run_dump_test pr30248 if {[is_elf_format] || [istarget "*-*-vxworks*"]} then { run_list_test_stdin "list-1" "-al" run_list_test_stdin "list-2" "-al" diff --git a/gas/testsuite/gas/i386/pr30248.d b/gas/testsuite/gas/i386/pr30248.d new file mode 100644 index 00000000000..a6efd26e2c5 --- /dev/null +++ b/gas/testsuite/gas/i386/pr30248.d @@ -0,0 +1,2 @@ +#as: +#error_output: pr30248.err diff --git a/gas/testsuite/gas/i386/pr30248.err b/gas/testsuite/gas/i386/pr30248.err new file mode 100644 index 00000000000..1f71543e1d4 --- /dev/null +++ b/gas/testsuite/gas/i386/pr30248.err @@ -0,0 +1,5 @@ +#failif + +#... +.*Internal error.* +#pass diff --git a/gas/testsuite/gas/i386/pr30248.s b/gas/testsuite/gas/i386/pr30248.s new file mode 100644 index 00000000000..ab875008f3d --- /dev/null +++ b/gas/testsuite/gas/i386/pr30248.s @@ -0,0 +1,2 @@ + .text + lgs ")""" -- 2.39.2