VBOX: Only perform the printf format string sanitize functionality on those strings that are going to be consumed by vbox_log().

This commit is contained in:
Rom Walton 2015-08-28 17:24:00 -04:00
parent 6736f5958e
commit eaf9cb817d
2 changed files with 8 additions and 9 deletions

View File

@ -290,7 +290,7 @@ void VBOX_BASE::dump_vmguestlog_entries() {
vm_log_timestamp = current_timestamp;
msg = line.substr(line_pos, line.size() - line_pos);
sanitize_output(msg);
sanitize_format(msg);
vboxlog_msg(msg.c_str());
}
@ -598,13 +598,9 @@ int VBOX_BASE::write_floppy(std::string& data) {
return 1;
}
void VBOX_BASE::sanitize_output(std::string& output) {
string::iterator iter;
// Check for special characters used by printf and render them
// harmless
//
iter = output.begin();
void VBOX_BASE::sanitize_format(std::string& output) {
// Check for special characters used by printf and render them harmless
string::iterator iter = output.begin();
while (iter != output.end()) {
if (*iter == '%') {
// If we find '%', insert an additional '%' so that the we end up with
@ -617,10 +613,12 @@ void VBOX_BASE::sanitize_output(std::string& output) {
++iter;
}
}
}
void VBOX_BASE::sanitize_output(std::string& output) {
#ifdef _WIN32
// Remove \r from the log spew
iter = output.begin();
string::iterator iter = output.begin();
while (iter != output.end()) {
if (*iter == '\r') {
iter = output.erase(iter);

View File

@ -229,6 +229,7 @@ public:
virtual void lower_vm_process_priority() = 0;
virtual void reset_vm_process_priority() = 0;
static void sanitize_format(std::string& output);
static void sanitize_output(std::string& output);
virtual int launch_vboxsvc();