mirror of https://github.com/aria2/aria2
Don't use parseInt in cookie_helper
parent
f75402739b
commit
a879d75aaa
|
@ -65,6 +65,20 @@ std::string::const_iterator getNextDigit
|
||||||
}
|
}
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
||||||
|
namespace {
|
||||||
|
template<typename InputIterator>
|
||||||
|
int getInteger(InputIterator first, InputIterator last)
|
||||||
|
{
|
||||||
|
int res = 0;
|
||||||
|
// We assume *dest won't overflow.
|
||||||
|
for(; first != last; ++first) {
|
||||||
|
res *= 10;
|
||||||
|
res += (*first)-'0';
|
||||||
|
}
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
} // namespace
|
||||||
|
|
||||||
bool parseDate
|
bool parseDate
|
||||||
(time_t& time,
|
(time_t& time,
|
||||||
std::string::const_iterator first,
|
std::string::const_iterator first,
|
||||||
|
@ -117,9 +131,9 @@ bool parseDate
|
||||||
goto NOT_TIME;
|
goto NOT_TIME;
|
||||||
}
|
}
|
||||||
foundTime = true;
|
foundTime = true;
|
||||||
hour = util::parseInt(std::string((*i).begin(), hEnd));
|
hour = getInteger((*i).begin(), hEnd);
|
||||||
minute = util::parseInt(std::string(hEnd+1, mEnd));
|
minute = getInteger(hEnd+1, mEnd);
|
||||||
second = util::parseInt(std::string(mEnd+1, sEnd));
|
second = getInteger(mEnd+1, sEnd);
|
||||||
continue;
|
continue;
|
||||||
NOT_TIME:
|
NOT_TIME:
|
||||||
;
|
;
|
||||||
|
@ -129,7 +143,7 @@ bool parseDate
|
||||||
size_t len = std::distance((*i).begin(), j);
|
size_t len = std::distance((*i).begin(), j);
|
||||||
if(1 <= len && len <= 2) {
|
if(1 <= len && len <= 2) {
|
||||||
foundDayOfMonth = true;
|
foundDayOfMonth = true;
|
||||||
dayOfMonth = util::parseInt(std::string((*i).begin(), j));
|
dayOfMonth = getInteger((*i).begin(), j);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -160,7 +174,7 @@ bool parseDate
|
||||||
size_t len = std::distance((*i).begin(), j);
|
size_t len = std::distance((*i).begin(), j);
|
||||||
if(1 <= len && len <= 4) {
|
if(1 <= len && len <= 4) {
|
||||||
foundYear = true;
|
foundYear = true;
|
||||||
year = util::parseInt(std::string((*i).begin(), j));
|
year = getInteger((*i).begin(), j);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue