mirror of
https://github.com/Zenithsiz/ftmemsim-valgrind.git
synced 2026-02-03 18:13:01 +00:00
XML output: escape XML-metacharacters in executable path and arguments. This is a modified version of the patch submitted by Evgeniy Stepanov <eugeni.stepanov@gmail.com>. See also #284621.
git-svn-id: svn://svn.valgrind.org/valgrind/trunk@12188
This commit is contained in:
parent
1fd197db11
commit
72cd30c206
@ -1026,21 +1026,26 @@ static void print_file_vars(Char* format)
|
||||
/*=== Printing the preamble ===*/
|
||||
/*====================================================================*/
|
||||
|
||||
// Print the command, escaping any chars that require it.
|
||||
static void umsg_or_xml_arg(const Char* arg,
|
||||
UInt (*umsg_or_xml)( const HChar*, ... ) )
|
||||
// Print the argument, escaping any chars that require it.
|
||||
static void umsg_arg(const Char* arg)
|
||||
{
|
||||
SizeT len = VG_(strlen)(arg);
|
||||
Char* special = " \\<>";
|
||||
Int i;
|
||||
for (i = 0; i < len; i++) {
|
||||
if (VG_(strchr)(special, arg[i])) {
|
||||
umsg_or_xml("\\"); // escape with a backslash if necessary
|
||||
VG_(umsg)("\\"); // escape with a backslash if necessary
|
||||
}
|
||||
umsg_or_xml("%c", arg[i]);
|
||||
VG_(umsg)("%c", arg[i]);
|
||||
}
|
||||
}
|
||||
|
||||
// Send output to the XML-stream and escape any XML meta-characters.
|
||||
static void xml_arg(const Char* arg)
|
||||
{
|
||||
VG_(printf_xml)("%pS", arg);
|
||||
}
|
||||
|
||||
/* Ok, the logging sink is running now. Print a suitable preamble.
|
||||
If logging to file or a socket, write details of parent PID and
|
||||
command line args, to help people trying to interpret the
|
||||
@ -1055,6 +1060,9 @@ static void print_preamble ( Bool logging_to_fd,
|
||||
UInt (*umsg_or_xml)( const HChar*, ... )
|
||||
= VG_(clo_xml) ? VG_(printf_xml) : VG_(umsg);
|
||||
|
||||
UInt (*umsg_or_xml_arg)( const HChar* )
|
||||
= VG_(clo_xml) ? xml_arg : umsg_arg;
|
||||
|
||||
vg_assert( VG_(args_for_client) );
|
||||
vg_assert( VG_(args_for_valgrind) );
|
||||
vg_assert( toolname );
|
||||
@ -1106,11 +1114,12 @@ static void print_preamble ( Bool logging_to_fd,
|
||||
// favour utility and simplicity over aesthetics.
|
||||
umsg_or_xml("%sCommand: ", xpre);
|
||||
if (VG_(args_the_exename))
|
||||
umsg_or_xml_arg(VG_(args_the_exename), umsg_or_xml);
|
||||
umsg_or_xml_arg(VG_(args_the_exename));
|
||||
|
||||
for (i = 0; i < VG_(sizeXA)( VG_(args_for_client) ); i++) {
|
||||
HChar* s = *(HChar**)VG_(indexXA)( VG_(args_for_client), i );
|
||||
umsg_or_xml(" ");
|
||||
umsg_or_xml_arg(s, umsg_or_xml);
|
||||
umsg_or_xml_arg(s);
|
||||
}
|
||||
umsg_or_xml("%s\n", xpost);
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user