From patchwork Mon Sep 25 14:48:39 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: 726044 Delivered-To: patch@linaro.org Received: by 2002:adf:ea87:0:b0:31d:da82:a3b4 with SMTP id s7csp2439014wrm; Mon, 25 Sep 2023 08:02:52 -0700 (PDT) X-Google-Smtp-Source: AGHT+IH1i8s3xXcnfy7yR0vppFCiugnUAIUmslwAavf5aramO7hBSOhIHUCJ7DgdrGtEKEvqjwcp X-Received: by 2002:a05:620a:51d0:b0:770:f3ed:bbc8 with SMTP id cx16-20020a05620a51d000b00770f3edbbc8mr5547224qkb.65.1695654171890; Mon, 25 Sep 2023 08:02:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1695654171; cv=none; d=google.com; s=arc-20160816; b=bHvrqNHbjiidSY/cZ4Jq4eaWLmN8Qyy030+jc1a//WhNg6Kai0P0yElpY6uh50ScUT mpxMEca1VTMWGxtbJngZRNjLVbNXenBBNPHbwlgQbq0YdKDe3/EyQikIZ/QhoM0OaqRz CewxC8rpTokUoncGNmshWzyk7byILFCHB/pkcASfqAR1GcWi0KPGgFDnF4dQC57DezPB eRhBnFjQNrxUYxkyCxs51IBHiiHT6AFjzm2YAwCM3Ax5DsMNNQGH0F3YPejITuaE5wQN HnysrcOCpTWUippsk8F7gvmyPYpANSQaJEh3RVIehohRfAZAA2AcVzgBdfix27ZXArMO mtsg== 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=Muj6oq//HewwqFNb1Dn6YA/ZLR4P4d92sjjuFTR9b6Q=; fh=mlkRjkvEMCBvV2NmkuZ9E+MTYOKspqfxSPvD1d2xG14=; b=glnWf52HjgCjFP6wSBUZTlR9ZeiKQ5zScLV3ho3gMj8P0YncQrxNPg98GEzGYNnufl VeQxXKcsmGLDWf30Y1gy0btfbiDPVxeA+Lu1GfpSk8QtRm8evqiXO+Ymx0NerYdOY7od 47AnTP519Cg3wsR1gZPdIDUT1ffaDLDqZvjaO/r1KBSjmn9Tpdj70Dd24jseTkBBUEvq zgDzloLJ7pg/dsYPMdQR/lABZDVPRxMB+TkT3vjgzJBuhk1wAnUSYDNjSzTBQGrUDQj5 yXfd9I/F2fdkdkNOSlVpo7iWvfjsNvGkmmKiajlD3Q8OyLkPdyETwAauAqYYuD7f8AUC rGZQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=DaaegImv; 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 qs16-20020a05620a395000b00765e579f0fesi6146414qkn.69.2023.09.25.08.02.51 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Mon, 25 Sep 2023 08:02:51 -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=DaaegImv; 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 1qkn3M-0000E9-5L; Mon, 25 Sep 2023 10:59: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 1qkn35-0008Kz-Bq for qemu-devel@nongnu.org; Mon, 25 Sep 2023 10:59:01 -0400 Received: from mail-wm1-x329.google.com ([2a00:1450:4864:20::329]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qkn2q-0002DV-IQ for qemu-devel@nongnu.org; Mon, 25 Sep 2023 10:58:51 -0400 Received: by mail-wm1-x329.google.com with SMTP id 5b1f17b1804b1-405361bb94eso66235435e9.0 for ; Mon, 25 Sep 2023 07:58:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1695653923; x=1696258723; 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=Muj6oq//HewwqFNb1Dn6YA/ZLR4P4d92sjjuFTR9b6Q=; b=DaaegImvntrWM+0vvPKYNhd6sA7GjTl+o5tlz4R6npR2z2/wRgCJfN9C3xiDIRdouo 2XiZGIV9cOJuF+PXI96z6vtYZxtEo4C2r1ctunPk35Z05/jh7MO96U3RnqTgTd5mzN8z qLSk6yNkPtU3z4vGNM/opijPcnxy5kckD/hn8A689cFfKGurS8G+zAp6xPOl3vX8ZzSP E6J8EkcmzOKLjcgA3REr/TGTzUAlfJBre36tM5Q3EHmFBDOIUZvAdIp2LlXBTS/2bACR 9JoaCUgaJKABViZN4eXGhfPJgoxzFaZdhEv+1BdgSQvYTrrpdUaHsBHQKL15HOUjAqyx KVew== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1695653923; x=1696258723; 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=Muj6oq//HewwqFNb1Dn6YA/ZLR4P4d92sjjuFTR9b6Q=; b=iSkrJWby/p9KOuxKeKCE/d4A3ipgB2yhz5je7082rPLcXF91WKNvQL7tmgZKTS57Jt vN3XtcDEzNuNxN0IwdtRLanw+QjOCbI+/ypC+CH5LeTZJcfgJ1uQrMh5tTrAGGXwtZdP 1HsRbhqCI+/v0riM1EwJYqkI7KvZ1KH9nRJrBcdQyUF19IJVdyROv+RA0JuYGVjXCUHh 2XwzKPbWMyanfSUuJKNR9K2+eT2Xi9iicHmdXPs9IFbFQpOvD33q2FOSRFugz9h1mn07 MtlsuR6t5oMQqJuyrne0z4uFPzVUIePH5MS8hVbg+fXqOWtu+4Ftft5U0zXwbImAcHWF xc4g== X-Gm-Message-State: AOJu0YyNC+WnXL8Q1Br1k1aWlF8uXKALXuf45tW4sgCapAEHu4ycCN1O 7u5MZnClrGm+O8up0L2uqDSeuA== X-Received: by 2002:a1c:770c:0:b0:405:3d41:5641 with SMTP id t12-20020a1c770c000000b004053d415641mr6365257wmi.15.1695653922843; Mon, 25 Sep 2023 07:58:42 -0700 (PDT) Received: from zen.linaroharston ([85.9.250.243]) by smtp.gmail.com with ESMTPSA id a3-20020a5d4d43000000b003177074f830sm12214244wru.59.2023.09.25.07.58.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 25 Sep 2023 07:58:42 -0700 (PDT) Received: from zen.linaroharston (localhost [127.0.0.1]) by zen.linaroharston (Postfix) with ESMTP id 078DE1FFC8; Mon, 25 Sep 2023 15:48:57 +0100 (BST) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: qemu-devel@nongnu.org Cc: Alistair Francis , =?utf-8?q?C=C3=A9dric_Le_Go?= =?utf-8?q?ater?= , Marcin Juszkiewicz , John Snow , libvir-list@redhat.com, =?utf-8?q?Marc-Andr?= =?utf-8?q?=C3=A9_Lureau?= , qemu-s390x@nongnu.org, Song Gao , Daniel Henrique Barboza , Marcel Apfelbaum , Bastian Koppelmann , Liu Zhiwei , Weiwei Li , Nicholas Piggin , Radoslaw Biernacki , =?utf-8?q?Daniel_P=2E_Berrang=C3=A9?= , Eduardo Habkost , Cleber Rosa , Paolo Bonzini , Mahmoud Mandour , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Thomas Huth , Wainer dos Santos Moschetta , Richard Henderson , Bin Meng , Alexandre Iooss , Xiaojuan Yang , qemu-ppc@nongnu.org, David Hildenbrand , =?utf-8?q?Alex_Benn=C3=A9e?= , Yanan Wang , Peter Maydell , qemu-riscv@nongnu.org, qemu-arm@nongnu.org, Palmer Dabbelt , Ilya Leoshkevich , Laurent Vivier , Yoshinori Sato , Leif Lindholm , Beraldo Leal , Akihiko Odaki Subject: [PATCH 16/31] gdbstub: Use g_markup_printf_escaped() Date: Mon, 25 Sep 2023 15:48:39 +0100 Message-Id: <20230925144854.1872513-17-alex.bennee@linaro.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230925144854.1872513-1-alex.bennee@linaro.org> References: <20230925144854.1872513-1-alex.bennee@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::329; envelope-from=alex.bennee@linaro.org; helo=mail-wm1-x329.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham 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 9db4af41c1..a4f2bf3723 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; }