[svn] commit: r1030 - /trunk/src/lib/dns/cpp/dnstime.cc
BIND 10 source code commits
bind10-changes at lists.isc.org
Sat Feb 27 19:14:13 UTC 2010
Author: each
Date: Sat Feb 27 19:14:12 2010
New Revision: 1030
Log:
- in the fromText function, check string length before sscanf(),
and use DATE_LEN enum instead of hard-coding the value 14
Modified:
trunk/src/lib/dns/cpp/dnstime.cc
Modified: trunk/src/lib/dns/cpp/dnstime.cc
==============================================================================
--- trunk/src/lib/dns/cpp/dnstime.cc (original)
+++ trunk/src/lib/dns/cpp/dnstime.cc Sat Feb 27 19:14:12 2010
@@ -40,6 +40,10 @@
namespace isc {
namespace dns {
+enum {
+ DATE_LEN = 14 // YYYYMMDDHHmmSS
+};
+
string
DNSSECTimeToText(const time_t timeval)
{
@@ -80,8 +84,10 @@
// 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());
More information about the bind10-changes
mailing list