[Boost-bugs] [Boost C++ Libraries] #1481: transform_width may cause buffer overruns

Subject: [Boost-bugs] [Boost C++ Libraries] #1481: transform_width may cause buffer overruns
From: Boost C++ Libraries (noreply_at_[hidden])
Date: 2007-11-28 15:55:36


#1481: transform_width may cause buffer overruns
-----------------------+----------------------------------------------------
 Reporter: anonymous | Type: Bugs
   Status: new | Milestone: To Be Determined
Component: None | Version: release 1.34.0
 Severity: Problem | Keywords:
-----------------------+----------------------------------------------------
 When using boost::archive::iterators::transform_width iterator for e.g.
 base64 encoding, and number of input bits does not fit into an integer
 number of output bits, the iterator dereferences an element beyond the
 last available.

 Consider this piece of code:

 {{{
 typedef std::vector<unsigned char> bytes;

 bytes b;
 b.push_back(1);

 typedef
     base64_from_binary<
         transform_width<
              bytes::const_iterator,
              6,
              sizeof(bytes::value_type) * 8, char> > base64;

 std::stringstream o;
 std::copy(base64(b.begin()), base64(b.end()),
 std::ostream_iterator<char>(o));
 }}}

 Provided vector::const_iterator implementation does checks against
 dereferencing an invalid iterator (e.g. vc8 stl), the above code will
 assert, because of an attempt to read the second (non-existant) element
 from the vector

--
Ticket URL: <http://svn.boost.org/trac/boost/ticket/1481>
Boost C++ Libraries <http://www.boost.org/>
Boost provides free peer-reviewed portable C++ source libraries.


This archive was generated by hypermail 2.1.7 : 2017-02-16 18:49:57 UTC