From patchwork Wed Oct 11 10:33:19 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: 731948 Delivered-To: patch@linaro.org Received: by 2002:a5d:54d1:0:b0:31d:da82:a3b4 with SMTP id x17csp326575wrv; Wed, 11 Oct 2023 03:36:32 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFP9rfwll4HZqlauH/U5H3RDp8cibgeauDSnwZ26c1bVZZA2yomZ8M87x2traiYZpkXrL/m X-Received: by 2002:a05:6902:251:b0:d86:5844:a897 with SMTP id k17-20020a056902025100b00d865844a897mr18293464ybs.5.1697020592489; Wed, 11 Oct 2023 03:36:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1697020592; cv=none; d=google.com; s=arc-20160816; b=RXlqEt4ByGdqdqvJZ6dKxmsAEsmxC4V1AsRK3Heg/1DGBK1rwWlFY3YprIvXrLz1lF 8ZInXhXnGaPpU966w2k4MLuk2NGYEi2bbrV9HNY/wVBdc/Ciiqw3h5dtWjVgSDiwxQRm WhgVWiGxYwrSgZPLcw8EvWNZPIFhStX+AMq45Waf8BoQU81H8cDppDz9b/2Hn09VZg/M WwSMKw0DWvbx5LziHlQvaVLzKobIiQhzOiyvyi7Cx2mvCCwJBqG4WNZf3dOV1P+Iyjit 7ie6UHx9cCsPEHXiXNDvuVm7hxMP8fN0VnibL1JqDZKeH5oxloYEp9t8xADR+RjsWpX/ XnaQ== 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=0GGDMjiObwuIV+sEPGodU7jxWDpthevn5Vhw1E3Gt5g=; fh=h9eGh9LdnczKeJ5s9ZJz3SDfuNraEHiWEOL+l5dy014=; b=S4uRQ7YThNxEoUbPYKNW+/3eKFLwiZYoay8DPZQtYJPt8UFu97aEYLnLsxkkZDv2Zi DuA0rcAoKlu+K7xBMb7cHDUQTyosV53E/wkT9Hq6Hm/kx5rlb6YweMJ83GtXPNZNRosZ DgtuwcICrNHLcW2lRsE+IfjMdf5AjShQ3LmCzGlTA6i6Ga+Zxpi56zlk8m60hmKThH4c AbMhy0f6XvyOaVLbKXpID3YHpaVsBNtoBfGETj2pKYdbsykcP3PiWmhx0J+ZFVkaxuEl pYY5q6tjtizCTIVdSJdXUZHMcQvMY7hc1xumU9xnvb/eWNWcT2RlOYIAcZBLHktcCVQ9 p46A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=kEDeUdYL; 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 n3-20020a0c8c03000000b006472f570d00si9100377qvb.181.2023.10.11.03.36.32 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Wed, 11 Oct 2023 03:36:32 -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=kEDeUdYL; 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 1qqWXL-0001cD-3T; Wed, 11 Oct 2023 06:33:55 -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 1qqWX9-0001MW-LT for qemu-devel@nongnu.org; Wed, 11 Oct 2023 06:33:45 -0400 Received: from mail-wm1-x32b.google.com ([2a00:1450:4864:20::32b]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qqWX5-0005Fn-R5 for qemu-devel@nongnu.org; Wed, 11 Oct 2023 06:33:43 -0400 Received: by mail-wm1-x32b.google.com with SMTP id 5b1f17b1804b1-405361bba99so61509515e9.2 for ; Wed, 11 Oct 2023 03:33:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1697020417; x=1697625217; 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=0GGDMjiObwuIV+sEPGodU7jxWDpthevn5Vhw1E3Gt5g=; b=kEDeUdYLFo13z/NWmn6GI8mwLxYmhMsTn/E8ORFEp4qdii2aDeOz8H7YiuE52XXqIa o+EQ58/l9V5ijsJNKJ4Do+jHZKHwRM05Gbx+z0+GMrFmbQCGG2/N88gC01FJNDfL28Ab 0OdeYpSvZ5QgcUD+TZ7jV/Ofoy8QeSjKjCj3X+CITFQUKMTptX8JdKN0cC15WY87djV6 fRrFKNuQWYuCfSzPTNhLIDv/MxfJVmApN0TgzFIUr2FueS4FzUsbAwe14y7hIGzcFEye Pr+z/UVAjIG5SJgTIBspu7VMUgHWGoSN4vtvHFT2EC3POAAfbtQ7hW3Lcl412cCiX8p0 hE+A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1697020417; x=1697625217; 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=0GGDMjiObwuIV+sEPGodU7jxWDpthevn5Vhw1E3Gt5g=; b=MFZvwH54FaoFW28uVz4A9I8k1hqE7lqg0cZuBg8RcloLoRiQ3+T1eNOZ0FN/Kt8ir6 sbt8pCii8Rq1H1bko3ipBnGZd7WxDAsz4c+ah8C54e8DMAtK+bTt4QoKFZWjJiaWLis5 KZeciEo8W3FvNaSB9yEkoT63BldpwZOm+I3wrclwmINbIa5LFDIkQPAYrORbTrVuiLB/ FmOmH6gwHwTqcVVX8FdE6B6hkpyrlbsbvNpLkJLC/bD9hFxf5Q/FovPLeWZ8k+ZuN112 +JME+H9GUYFaNB1CMo3ea9OrBYsAoVr7eFk/NQUH6OufIksvo0IGOGhdfTwMdqucleWI jtEw== X-Gm-Message-State: AOJu0YxK564PJFIeIQLdIDLusvT3F1281tV9isT/jNVzswkxHWhmIWyg Cy2FcIdMwzoDfhvTQBLnhCv6Lw== X-Received: by 2002:a1c:7209:0:b0:405:a30:151e with SMTP id n9-20020a1c7209000000b004050a30151emr18905129wmc.12.1697020417661; Wed, 11 Oct 2023 03:33:37 -0700 (PDT) Received: from zen.linaroharston ([85.9.250.243]) by smtp.gmail.com with ESMTPSA id f19-20020a1c6a13000000b00402d34ea099sm18671708wmc.29.2023.10.11.03.33.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 11 Oct 2023 03:33:35 -0700 (PDT) Received: from zen.linaroharston (localhost [127.0.0.1]) by zen.linaroharston (Postfix) with ESMTP id D37081FFC7; Wed, 11 Oct 2023 11:33:31 +0100 (BST) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: qemu-devel@nongnu.org Cc: Akihiko Odaki , =?utf-8?q?Alex_Benn=C3=A9e?= , =?utf-8?q?Philippe_M?= =?utf-8?q?athieu-Daud=C3=A9?= Subject: [PULL 15/25] gdbstub: Use g_markup_printf_escaped() Date: Wed, 11 Oct 2023 11:33:19 +0100 Message-Id: <20231011103329.670525-16-alex.bennee@linaro.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20231011103329.670525-1-alex.bennee@linaro.org> References: <20231011103329.670525-1-alex.bennee@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::32b; envelope-from=alex.bennee@linaro.org; helo=mail-wm1-x32b.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 Message-Id: <20231009164104.369749-16-alex.bennee@linaro.org> 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; }