diff options
author | Robin Gareus <robin@gareus.org> | 2020-04-23 02:25:38 +0200 |
---|---|---|
committer | Robin Gareus <robin@gareus.org> | 2020-04-23 02:25:38 +0200 |
commit | 705ac7bfc5cc3e4d793a3c1faa3326d1627679a7 (patch) | |
tree | 4aeb8601f566b17f972fce7a44118780fb45eb12 /libs | |
parent | 3d166c77891c2a83de35c5fd10c0b23c131bc43b (diff) |
Prevent huge stack allocations for MIDNAM files
xmlParseMemory() uses a c-pointer char*.
Previously MIDNAM data on the heap were wrapped inside
a std::string only to be later accessed via c_str().
Diffstat (limited to 'libs')
-rw-r--r-- | libs/ardour/ardour/midi_patch_manager.h | 4 | ||||
-rw-r--r-- | libs/ardour/midi_patch_manager.cc | 4 | ||||
-rw-r--r-- | libs/pbd/pbd/xml++.h | 2 | ||||
-rw-r--r-- | libs/pbd/xml++.cc | 4 |
4 files changed, 7 insertions, 7 deletions
diff --git a/libs/ardour/ardour/midi_patch_manager.h b/libs/ardour/ardour/midi_patch_manager.h index 148a946c3a..cb4f492bc4 100644 --- a/libs/ardour/ardour/midi_patch_manager.h +++ b/libs/ardour/ardour/midi_patch_manager.h @@ -64,8 +64,8 @@ public: PBD::Signal0<void> PatchesChanged; - bool add_custom_midnam (const std::string& id, const std::string& midnam); - bool update_custom_midnam (const std::string& id, const std::string& midnam); + bool add_custom_midnam (const std::string& id, char const*); + bool update_custom_midnam (const std::string& id, char const*); bool remove_custom_midnam (const std::string& id); bool is_custom_model (const std::string& model) const; diff --git a/libs/ardour/midi_patch_manager.cc b/libs/ardour/midi_patch_manager.cc index 1ceaa17924..82dd38a240 100644 --- a/libs/ardour/midi_patch_manager.cc +++ b/libs/ardour/midi_patch_manager.cc @@ -81,7 +81,7 @@ MidiPatchManager::add_search_path (const Searchpath& search_path) } bool -MidiPatchManager::add_custom_midnam (const std::string& id, const std::string& midnam) +MidiPatchManager::add_custom_midnam (const std::string& id, char const* midnam) { boost::shared_ptr<MIDINameDocument> document; document = boost::shared_ptr<MIDINameDocument>(new MIDINameDocument()); @@ -103,7 +103,7 @@ MidiPatchManager::remove_custom_midnam (const std::string& id) } bool -MidiPatchManager::update_custom_midnam (const std::string& id, const std::string& midnam) +MidiPatchManager::update_custom_midnam (const std::string& id, char const* midnam) { Glib::Threads::Mutex::Lock lm (_lock); remove_midi_name_document ("custom:" + id, false); diff --git a/libs/pbd/pbd/xml++.h b/libs/pbd/pbd/xml++.h index e4e28c4655..d17f77bd3c 100644 --- a/libs/pbd/pbd/xml++.h +++ b/libs/pbd/pbd/xml++.h @@ -91,7 +91,7 @@ public: bool read(const std::string& fn) { set_filename(fn); return read_internal(false); } bool read_and_validate() { return read_internal(true); } bool read_and_validate(const std::string& fn) { set_filename(fn); return read_internal(true); } - bool read_buffer(const std::string&, bool to_tree_doc = false); + bool read_buffer(char const*, bool to_tree_doc = false); bool write() const; bool write(const std::string& fn) { set_filename(fn); return write(); } diff --git a/libs/pbd/xml++.cc b/libs/pbd/xml++.cc index e09af7602b..bb2dd3e7ca 100644 --- a/libs/pbd/xml++.cc +++ b/libs/pbd/xml++.cc @@ -124,7 +124,7 @@ XMLTree::read_internal(bool validate) } bool -XMLTree::read_buffer(const string& buffer, bool to_tree_doc) +XMLTree::read_buffer (char const* buffer, bool to_tree_doc) { xmlDocPtr doc; @@ -133,7 +133,7 @@ XMLTree::read_buffer(const string& buffer, bool to_tree_doc) delete _root; _root = 0; - doc = xmlParseMemory(const_cast<char*>(buffer.c_str()), buffer.length()); + doc = xmlParseMemory (buffer, strlen(buffer)); if (!doc) { return false; } |