Skip to content

Commit

Permalink
fix address sanitizer exception when loading corrupted XML archive. G…
Browse files Browse the repository at this point in the history
…itHub issue boostorg#257
  • Loading branch information
robertramey committed Sep 16, 2022
1 parent df2e670 commit 3f322d4
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion include/boost/archive/impl/basic_xml_iarchive.ipp
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@

#include <boost/assert.hpp>
#include <cstddef> // NULL
#include <cstring> // strlen
#include <algorithm>

#include <boost/serialization/throw_exception.hpp>
Expand Down Expand Up @@ -58,7 +59,10 @@ basic_xml_iarchive<Archive>::load_end(const char *name){

if(0 == (this->get_flags() & no_xml_tag_checking)){
// double check that the tag matches what is expected - useful for debug
if(0 != name[this->This()->gimpl->rv.object_name.size()]
std::size_t parameter_name_length = std::strlen(name);
std::size_t object_name_length = this->This()->gimpl->rv.object_name.size();

if(parameter_name_length != object_name_length
|| ! std::equal(
this->This()->gimpl->rv.object_name.begin(),
this->This()->gimpl->rv.object_name.end(),
Expand Down

0 comments on commit 3f322d4

Please sign in to comment.