[Boost-bugs] [Boost C++ Libraries] #8284: Protect from using boost::asio::buffer() with non-pod std::vector

Subject: [Boost-bugs] [Boost C++ Libraries] #8284: Protect from using boost::asio::buffer() with non-pod std::vector
From: Boost C++ Libraries (noreply_at_[hidden])
Date: 2013-03-12 10:26:53


#8284: Protect from using boost::asio::buffer() with non-pod std::vector
-----------------------------------+----------------------------------------
 Reporter: boost.lists@… | Owner: chris_kohlhoff
     Type: Patches | Status: new
Milestone: To Be Determined | Component: asio
  Version: Boost 1.53.0 | Severity: Optimization
 Keywords: asio |
-----------------------------------+----------------------------------------
 The following code produces UB:
 {{{#!cpp
 #include <vector>
 #include <string>
 #include <boost/asio.hpp>

 int main()
 {
   using namespace std;
   using namespace boost::asio;
   io_service service;
   ip::tcp::acceptor acceptor(service, ip::tcp::endpoint(ip::tcp::v4(),
 123));
   ip::tcp::socket sock(service);
   acceptor.accept(sock);
   string s = "qwerty";
   vector<const_buffer> v;
   v.push_back(buffer(s));
   write(sock, buffer(v)); // should be: write(sock, v);
 }
 }}}

 Such a misuse can be prevented using enable_if<is_pod<...>> (see attached
 patch).

-- 
Ticket URL: <https://svn.boost.org/trac/boost/ticket/8284>
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:50:12 UTC