svn commit: r267156 - stable/10/sys/geom/part

Andrey V. Elsukov ae at FreeBSD.org
Fri Jun 6 12:37:57 UTC 2014


Author: ae
Date: Fri Jun  6 12:37:56 2014
New Revision: 267156
URL: http://svnweb.freebsd.org/changeset/base/267156

Log:
  MFC r266880:
    Use g_conf_printf_escaped() to escape symbols, which can break
    an XML tree.

Modified:
  stable/10/sys/geom/part/g_part_apm.c
  stable/10/sys/geom/part/g_part_gpt.c
  stable/10/sys/geom/part/g_part_pc98.c
Directory Properties:
  stable/10/   (props changed)

Modified: stable/10/sys/geom/part/g_part_apm.c
==============================================================================
--- stable/10/sys/geom/part/g_part_apm.c	Fri Jun  6 12:06:40 2014	(r267155)
+++ stable/10/sys/geom/part/g_part_apm.c	Fri Jun  6 12:37:56 2014	(r267156)
@@ -42,6 +42,7 @@ __FBSDID("$FreeBSD$");
 #include <sys/systm.h>
 #include <sys/sysctl.h>
 #include <geom/geom.h>
+#include <geom/geom_int.h>
 #include <geom/part/g_part.h>
 
 #include "g_part_if.h"
@@ -310,10 +311,14 @@ g_part_apm_dumpconf(struct g_part_table 
 		/* confxml: partition entry information */
 		strncpy(u.name, entry->ent.ent_name, APM_ENT_NAMELEN);
 		u.name[APM_ENT_NAMELEN] = '\0';
-		sbuf_printf(sb, "%s<label>%s</label>\n", indent, u.name);
+		sbuf_printf(sb, "%s<label>", indent);
+		g_conf_printf_escaped(sb, "%s", u.name);
+		sbuf_printf(sb, "</label>\n");
 		strncpy(u.type, entry->ent.ent_type, APM_ENT_TYPELEN);
 		u.type[APM_ENT_TYPELEN] = '\0';
-		sbuf_printf(sb, "%s<rawtype>%s</rawtype>\n", indent, u.type);
+		sbuf_printf(sb, "%s<rawtype>", indent);
+		g_conf_printf_escaped(sb, "%s", u.type);
+		sbuf_printf(sb, "</rawtype>\n");
 	} else {
 		/* confxml: scheme information */
 	}

Modified: stable/10/sys/geom/part/g_part_gpt.c
==============================================================================
--- stable/10/sys/geom/part/g_part_gpt.c	Fri Jun  6 12:06:40 2014	(r267155)
+++ stable/10/sys/geom/part/g_part_gpt.c	Fri Jun  6 12:37:56 2014	(r267156)
@@ -44,6 +44,7 @@ __FBSDID("$FreeBSD$");
 #include <sys/sysctl.h>
 #include <sys/uuid.h>
 #include <geom/geom.h>
+#include <geom/geom_int.h>
 #include <geom/part/g_part.h>
 
 #include "g_part_if.h"
@@ -1230,16 +1231,16 @@ g_gpt_printf_utf16(struct sbuf *sb, uint
 
 		/* 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));
 	}
 }

Modified: stable/10/sys/geom/part/g_part_pc98.c
==============================================================================
--- stable/10/sys/geom/part/g_part_pc98.c	Fri Jun  6 12:06:40 2014	(r267155)
+++ stable/10/sys/geom/part/g_part_pc98.c	Fri Jun  6 12:37:56 2014	(r267156)
@@ -300,7 +300,9 @@ g_part_pc98_dumpconf(struct g_part_table
 		sbuf_printf(sb, " xs PC98 xt %u sn %s", type, name);
 	} else {
 		/* confxml: partition entry information */
-		sbuf_printf(sb, "%s<label>%s</label>\n", indent, name);
+		sbuf_printf(sb, "%s<label>", indent);
+		g_conf_printf_escaped(sb, "%s", name);
+		sbuf_printf(sb, "</label>\n");
 		if (entry->ent.dp_mid & PC98_MID_BOOTABLE)
 			sbuf_printf(sb, "%s<attrib>bootable</attrib>\n",
 			    indent);


More information about the svn-src-stable-10 mailing list