From patchwork Mon Oct 9 16:40:54 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Alex_Benn=C3=A9e?= X-Patchwork-Id: 731023 Delivered-To: patch@linaro.org Received: by 2002:a5d:574c:0:b0:31d:da82:a3b4 with SMTP id q12csp1313367wrw; Mon, 9 Oct 2023 09:48:30 -0700 (PDT) X-Google-Smtp-Source: AGHT+IF0HsbsiZRji9ipVdyqkZEsvXFCSiPuuHVx0fjwR5pY7n3RaKsyjgHjFM4fgNnrwuEum0eR X-Received: by 2002:a05:6870:ea9e:b0:1d6:5483:75e7 with SMTP id s30-20020a056870ea9e00b001d6548375e7mr19499686oap.13.1696870109938; Mon, 09 Oct 2023 09:48:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1696870109; cv=none; d=google.com; s=arc-20160816; b=B5epnCMoenI+I9/LIwHDhRosSZjFY9DIzLKbprFZMuoxaERitap/S3xvWpD4INHDzu Wp6V7BRuqYlY8Ill5KsdAF8ci/nt4E3mSHdWtY5hTKkyUeHcok4WCAGuoUv3kqBvW1hh Ku1TL23MBKR+HwXVCnXnexiGQ/88SxCyiwitOcDkomT+DkUxrBYp4l0YQ0EWkEb5qSAD cKTiwBUSY+5AhH3JRS7IF+ofSFJ2y2dQoNsSnwY+xd83+NrlpuOjH8vU7EsePLnoVa03 CC4iGEUa6W9DnQH/Z/tM6l0ENDG6ZSODfa0rGLFvKigpTjpA9vMmPspnaXwy8ngrO1nG /2UA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=BaWzj6TOawybEbZLkphNAwpwFijNfIuoCtyzRhLAt7Q=; fh=FL21b9FDJBPKO4Cw1gBqBPIr8gb5CEXpVKTgM6hLIl8=; b=AV8Y3x5JERLPEYQDQMwYWKGvAnLC0zQMk9i6r/KjcM2s/3/rxAtetCMHjDtMClNN9t OFzlxsQhpN/7w2hYW/Kr89ZApxiPPawXrnhX5stKmj6DwtO8g+FwA+4b2fpiMbJBt9Vh 0FmmAq1EORZVjPoa7TeqcA1CJ2IFm+mrdL5bYZqbCeEClQDaZGLrgL2L+iXf1YuyFc9d p5pdeLt36n3/thBfP1NWbc/wPipXfB0Zz5xjlYCjLPLZzbAThgzVXDkKuPFX4aAYqOB8 3GxxuX/hO0eVPiAv46Dvx6UeZp1zWC0D9so1wlgeuaDBBd0EPTmL+wBdjzIg6PNPguki ivng== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=iUI60xtk; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id p19-20020a0ce193000000b00656351ccd89si6274456qvl.233.2023.10.09.09.48.29 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Mon, 09 Oct 2023 09:48:29 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=iUI60xtk; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qptPY-0005DB-LT; Mon, 09 Oct 2023 12:47:16 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qptP3-0003E0-CY for qemu-devel@nongnu.org; Mon, 09 Oct 2023 12:46:55 -0400 Received: from mail-wm1-x333.google.com ([2a00:1450:4864:20::333]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qptOk-0003Xo-Ok for qemu-devel@nongnu.org; Mon, 09 Oct 2023 12:46:44 -0400 Received: by mail-wm1-x333.google.com with SMTP id 5b1f17b1804b1-40566f89f6eso47937655e9.3 for ; Mon, 09 Oct 2023 09:46:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1696869975; x=1697474775; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=BaWzj6TOawybEbZLkphNAwpwFijNfIuoCtyzRhLAt7Q=; b=iUI60xtkpw4burOise8ES76WJJV8hA6xDxAUAOYqoU+c8QvQ5+rtCCs4EK3LLNuySq 0+nm6B+BzUJjWsl1h0sd2BVoJtKGxVHIGjx+U+llU3plLwYkWJMsu0V4wCzkgzyzvXN6 +xzCukTAl9lUJizcmsquB9DJbaVJaHYDgXIK9ZdT4pwMrgoZsCDD9yilqG7MYjYmnHSy FRCP9j50egevjdHC5oMMiQ4rXgtFr7ad1MTC7vB2vXWZZNPkjRh+tsME7oXj5yepvQA1 FycO1jWkfYlO4jRqE99F7Anz9+fUJcwS01XbtY/N49Fb+RQLdbtayAx2xzZJFmLOmkGb +I6Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1696869975; x=1697474775; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=BaWzj6TOawybEbZLkphNAwpwFijNfIuoCtyzRhLAt7Q=; b=axRWjrkdzc1n8MUSmIfXc9A1RO4evti6gExgPrgvfqH6mh7wH86TkNgLzBwkkYLINJ yU8qh+2kHZ5ZrYtlNkYVqDnLzW1WAfu2kBBsl11Ak4YqU06Sf6ForWJXX5vMQPByd2IZ FSzaTXIqmjGYmCkYZsXMwWSb8PkzfQdJlk50oCoMVzWEpBkyF9U9iW7tszhQYhxKY12R Y4ffZ22fXH9/a5saZtpwAl8VOhz1nDK9wcd4p2QGDyb2L2o/i0Gv+oz28WdCKtNtWFc3 zTfg7dDKKWyctGXKFdpkYWuGFq4WIBhg6NHZkZ0WHJ04NHm8hczAJL3j/pBKppZt1MNo XSKQ== X-Gm-Message-State: AOJu0YzcgLXJ+Gc49myj1b1koExjHw/2xPjAy0rlWA1Uv7L+Yfr3cv1+ THDx1h4TAeJL7vV23XIDx/gapQ== X-Received: by 2002:a05:600c:2298:b0:3fb:a100:2581 with SMTP id 24-20020a05600c229800b003fba1002581mr14279362wmf.14.1696869975132; Mon, 09 Oct 2023 09:46:15 -0700 (PDT) Received: from zen.linaroharston ([85.9.250.243]) by smtp.gmail.com with ESMTPSA id e24-20020a05600c219800b004013797efb6sm13936639wme.9.2023.10.09.09.46.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 09 Oct 2023 09:46:13 -0700 (PDT) Received: from zen.linaroharston (localhost [127.0.0.1]) by zen.linaroharston (Postfix) with ESMTP id E9CD81FFC7; Mon, 9 Oct 2023 17:41:06 +0100 (BST) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: qemu-devel@nongnu.org Cc: Thomas Huth , Xiaojuan Yang , =?utf-8?q?C=C3=A9dric_Le_Goater?= , =?utf-8?q?Alex_Benn=C3=A9?= =?utf-8?q?e?= , Bastian Koppelmann , Brad Smith , Radoslaw Biernacki , David Hildenbrand , Cleber Rosa , Ilya Leoshkevich , qemu-riscv@nongnu.org, Daniel Henrique Barboza , Alexandre Iooss , Nicholas Piggin , Bin Meng , Leif Lindholm , Paolo Bonzini , Eduardo Habkost , Alistair Francis , qemu-ppc@nongnu.org, John Snow , Liu Zhiwei , qemu-arm@nongnu.org, Wainer dos Santos Moschetta , Palmer Dabbelt , Peter Maydell , Yanan Wang , Weiwei Li , =?utf-8?q?Daniel_P=2E_Berrang=C3=A9?= , Marcel Apfelbaum , Beraldo Leal , Yoshinori Sato , Mahmoud Mandour , Richard Henderson , Song Gao , Marcin Juszkiewicz , qemu-s390x@nongnu.org, =?utf-8?q?Marc-Andr=C3=A9_Lureau?= , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Akihiko Odaki Subject: [PATCH 15/25] gdbstub: Use g_markup_printf_escaped() Date: Mon, 9 Oct 2023 17:40:54 +0100 Message-Id: <20231009164104.369749-16-alex.bennee@linaro.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20231009164104.369749-1-alex.bennee@linaro.org> References: <20231009164104.369749-1-alex.bennee@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::333; envelope-from=alex.bennee@linaro.org; helo=mail-wm1-x333.google.com X-Spam_score_int: -16 X-Spam_score: -1.7 X-Spam_bar: - X-Spam_report: (-1.7 / 5.0 requ) BAYES_00=-1.9, DKIM_INVALID=0.1, DKIM_SIGNED=0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org From: Akihiko Odaki g_markup_printf_escaped() is a safer alternative to simple printf() as it automatically escapes values. Signed-off-by: Akihiko Odaki Message-Id: <20230912224107.29669-9-akihiko.odaki@daynix.com> Signed-off-by: Alex Bennée --- gdbstub/gdbstub.c | 36 +++++++++++++++++++++--------------- 1 file changed, 21 insertions(+), 15 deletions(-) diff --git a/gdbstub/gdbstub.c b/gdbstub/gdbstub.c index a20169c27b..3dc847f835 100644 --- a/gdbstub/gdbstub.c +++ b/gdbstub/gdbstub.c @@ -373,28 +373,34 @@ static const char *get_feature_xml(const char *p, const char **newp, if (strncmp(p, "target.xml", len) == 0) { if (!process->target_xml) { GDBRegisterState *r; - GString *xml = g_string_new(""); + g_autoptr(GPtrArray) xml = g_ptr_array_new_with_free_func(g_free); - g_string_append(xml, - "" - ""); + g_ptr_array_add( + xml, + g_strdup("" + "" + "")); if (cc->gdb_arch_name) { - g_string_append_printf(xml, - "%s", - cc->gdb_arch_name(cpu)); + g_ptr_array_add( + xml, + g_markup_printf_escaped("%s", + cc->gdb_arch_name(cpu))); } - g_string_append(xml, "gdb_core_xml_file); - g_string_append(xml, "\"/>"); + g_ptr_array_add( + xml, + g_markup_printf_escaped("", + cc->gdb_core_xml_file)); for (r = cpu->gdb_regs; r; r = r->next) { - g_string_append(xml, "xml); - g_string_append(xml, "\"/>"); + g_ptr_array_add( + xml, + g_markup_printf_escaped("", + r->xml)); } - g_string_append(xml, ""); + g_ptr_array_add(xml, g_strdup("")); + g_ptr_array_add(xml, NULL); - process->target_xml = g_string_free(xml, false); + process->target_xml = g_strjoinv(NULL, (void *)xml->pdata); } return process->target_xml; }