From 603c6eed4aec5d7fcd64431f3d83f197388eb813 Mon Sep 17 00:00:00 2001 From: ae Date: Fri, 6 Jun 2014 12:37:56 +0000 Subject: [PATCH] MFC r266880: Use g_conf_printf_escaped() to escape symbols, which can break an XML tree. git-svn-id: svn://svn.freebsd.org/base/stable/10@267156 ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f --- sys/geom/part/g_part_apm.c | 9 +++++++-- sys/geom/part/g_part_gpt.c | 11 ++++++----- sys/geom/part/g_part_pc98.c | 4 +++- 3 files changed, 16 insertions(+), 8 deletions(-) diff --git a/sys/geom/part/g_part_apm.c b/sys/geom/part/g_part_apm.c index 66c0295da..bb79e5681 100644 --- a/sys/geom/part/g_part_apm.c +++ b/sys/geom/part/g_part_apm.c @@ -42,6 +42,7 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #include #include "g_part_if.h" @@ -310,10 +311,14 @@ g_part_apm_dumpconf(struct g_part_table *table, struct g_part_entry *baseentry, /* confxml: partition entry information */ strncpy(u.name, entry->ent.ent_name, APM_ENT_NAMELEN); u.name[APM_ENT_NAMELEN] = '\0'; - sbuf_printf(sb, "%s\n", indent, u.name); + sbuf_printf(sb, "%s\n"); strncpy(u.type, entry->ent.ent_type, APM_ENT_TYPELEN); u.type[APM_ENT_TYPELEN] = '\0'; - sbuf_printf(sb, "%s%s\n", indent, u.type); + sbuf_printf(sb, "%s", indent); + g_conf_printf_escaped(sb, "%s", u.type); + sbuf_printf(sb, "\n"); } else { /* confxml: scheme information */ } diff --git a/sys/geom/part/g_part_gpt.c b/sys/geom/part/g_part_gpt.c index b547f0b8d..4af2868c0 100644 --- a/sys/geom/part/g_part_gpt.c +++ b/sys/geom/part/g_part_gpt.c @@ -44,6 +44,7 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #include #include "g_part_if.h" @@ -1230,16 +1231,16 @@ g_gpt_printf_utf16(struct sbuf *sb, uint16_t *str, size_t len) /* Write the Unicode character in UTF-8 */ if (ch < 0x80) - sbuf_printf(sb, "%c", ch); + g_conf_printf_escaped(sb, "%c", ch); else if (ch < 0x800) - sbuf_printf(sb, "%c%c", 0xc0 | (ch >> 6), + g_conf_printf_escaped(sb, "%c%c", 0xc0 | (ch >> 6), 0x80 | (ch & 0x3f)); else if (ch < 0x10000) - sbuf_printf(sb, "%c%c%c", 0xe0 | (ch >> 12), + g_conf_printf_escaped(sb, "%c%c%c", 0xe0 | (ch >> 12), 0x80 | ((ch >> 6) & 0x3f), 0x80 | (ch & 0x3f)); else if (ch < 0x200000) - sbuf_printf(sb, "%c%c%c%c", 0xf0 | (ch >> 18), - 0x80 | ((ch >> 12) & 0x3f), + g_conf_printf_escaped(sb, "%c%c%c%c", 0xf0 | + (ch >> 18), 0x80 | ((ch >> 12) & 0x3f), 0x80 | ((ch >> 6) & 0x3f), 0x80 | (ch & 0x3f)); } } diff --git a/sys/geom/part/g_part_pc98.c b/sys/geom/part/g_part_pc98.c index 07d6a6288..2012d2b28 100644 --- a/sys/geom/part/g_part_pc98.c +++ b/sys/geom/part/g_part_pc98.c @@ -300,7 +300,9 @@ g_part_pc98_dumpconf(struct g_part_table *table, sbuf_printf(sb, " xs PC98 xt %u sn %s", type, name); } else { /* confxml: partition entry information */ - sbuf_printf(sb, "%s\n", indent, name); + sbuf_printf(sb, "%s\n"); if (entry->ent.dp_mid & PC98_MID_BOOTABLE) sbuf_printf(sb, "%sbootable\n", indent); -- 2.45.0