Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r84646 - trunk/libs/log/src
From: andrey.semashev_at_[hidden]
Date: 2013-06-05 16:12:56


Author: andysem
Date: 2013-06-05 16:12:56 EDT (Wed, 05 Jun 2013)
New Revision: 84646
URL: http://svn.boost.org/trac/boost/changeset/84646

Log:
Changed attribute name ordering predicate so that non-typical char_traits::compare implementations don't issue buffer overruns.

Text files modified:
   trunk/libs/log/src/attribute_name.cpp | 12 ++++--------
   1 files changed, 4 insertions(+), 8 deletions(-)

Modified: trunk/libs/log/src/attribute_name.cpp
==============================================================================
--- trunk/libs/log/src/attribute_name.cpp Wed Jun 5 16:04:10 2013 (r84645)
+++ trunk/libs/log/src/attribute_name.cpp 2013-06-05 16:12:56 EDT (Wed, 05 Jun 2013) (r84646)
@@ -13,6 +13,7 @@
  * at http://www.boost.org/libs/log/doc/log.html.
  */
 
+#include <cstring>
 #include <deque>
 #include <ostream>
 #include <stdexcept>
@@ -80,23 +81,18 @@
         struct order_by_name
         {
             typedef bool result_type;
- typedef string_type::traits_type traits_type;
 
             bool operator() (node const& left, node const& right) const
             {
- // Include terminating 0 into comparison to also check the length match
- return traits_type::compare(
- left.m_name.c_str(), right.m_name.c_str(), left.m_name.size() + 1) < 0;
+ return std::strcmp(left.m_name.c_str(), right.m_name.c_str()) < 0;
             }
             bool operator() (node const& left, const char* right) const
             {
- // Include terminating 0 into comparison to also check the length match
- return traits_type::compare(left.m_name.c_str(), right, left.m_name.size() + 1) < 0;
+ return std::strcmp(left.m_name.c_str(), right) < 0;
             }
             bool operator() (const char* left, node const& right) const
             {
- // Include terminating 0 into comparison to also check the length match
- return traits_type::compare(left, right.m_name.c_str(), right.m_name.size() + 1) < 0;
+ return std::strcmp(left, right.m_name.c_str()) < 0;
             }
         };
 


Boost-Commit list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk