Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r53485 - trunk/boost/date_time
From: andrey.semashev_at_[hidden]
Date: 2009-05-31 08:03:42


Author: andysem
Date: 2009-05-31 08:03:41 EDT (Sun, 31 May 2009)
New Revision: 53485
URL: http://svn.boost.org/trac/boost/changeset/53485

Log:
Fixed a possible reading overflow in the var_string_to_int function.
Mentioned in ticket #1861.

-This line, and those below, will be ignored--

M format_date_parser.hpp

Text files modified:
   trunk/boost/date_time/format_date_parser.hpp | 10 +++++-----
   1 files changed, 5 insertions(+), 5 deletions(-)

Modified: trunk/boost/date_time/format_date_parser.hpp
==============================================================================
--- trunk/boost/date_time/format_date_parser.hpp (original)
+++ trunk/boost/date_time/format_date_parser.hpp 2009-05-31 08:03:41 EDT (Sun, 31 May 2009)
@@ -100,19 +100,19 @@
 inline
 int_type
 var_string_to_int(std::istreambuf_iterator<charT>& itr,
- std::istreambuf_iterator<charT>& /* stream_end */,
+ const std::istreambuf_iterator<charT>& stream_end,
                   unsigned int max_length)
 {
   typedef std::basic_string<charT> string_type;
   unsigned int j = 0;
   string_type s;
- while ((j < max_length) && std::isdigit(*itr)) {
+ while (itr != stream_end && (j < max_length) && std::isdigit(*itr)) {
     s += (*itr);
- itr++;
- j++;
+ ++itr;
+ ++j;
   }
   int_type i = -1;
- if(s.length() != 0) {
+ if(!s.empty()) {
     i = boost::lexical_cast<int_type>(s);
   }
   return i;


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