Commit c3c47b30 authored by Evan Hunt's avatar Evan Hunt
Browse files

- in the fromText function, check string length before sscanf(),

  and use DATE_LEN enum instead of hard-coding the value 14


git-svn-id: svn://bind10.isc.org/svn/bind10/trunk@1030 e5f2f494-b856-4b98-b285-d166d9295462
parent 0bcbba63
......@@ -40,6 +40,10 @@ using namespace std;
namespace isc {
namespace dns {
enum {
DATE_LEN = 14 // YYYYMMDDHHmmSS
};
string
DNSSECTimeToText(const time_t timeval)
{
......@@ -80,8 +84,10 @@ DNSSECTimeFromText(const string& time_txt)
// first try reading YYYYMMDDHHmmSS format
int year, month, day, hour, minute, second;
if (sscanf(time_txt.c_str(), "%4d%2d%2d%2d%2d%2d",
&year, &month, &day, &hour, &minute, &second) != 6) {
if (time_txt.length() != DATE_LEN ||
sscanf(time_txt.c_str(), "%4d%2d%2d%2d%2d%2d",
&year, &month, &day, &hour, &minute, &second) != 6)
{
ostringstream oss;
oss << "Couldn't convert time value: " << time_txt;
dns_throw(InvalidTime, oss.str().c_str());
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment