diff options
author | Boris Kolpackov <boris@codesynthesis.com> | 2009-10-21 09:38:10 +0200 |
---|---|---|
committer | Boris Kolpackov <boris@codesynthesis.com> | 2009-10-21 09:38:10 +0200 |
commit | 97081a30ee6a4ba5db2ad9d54017a6709b358eec (patch) | |
tree | c08d6f8e42783e6c1430b55ac5a781c64b405634 /libxsde/xsde/cxx/parser | |
parent | 15d20d2337ca97c8c6b274c8781075d10863b1f7 (diff) |
Make sure values are positive since strtoul does not
Diffstat (limited to 'libxsde/xsde/cxx/parser')
-rw-r--r-- | libxsde/xsde/cxx/parser/validating/duration.cxx | 46 |
1 files changed, 43 insertions, 3 deletions
diff --git a/libxsde/xsde/cxx/parser/validating/duration.cxx b/libxsde/xsde/cxx/parser/validating/duration.cxx index 9d72609..50bf1a8 100644 --- a/libxsde/xsde/cxx/parser/validating/duration.cxx +++ b/libxsde/xsde/cxx/parser/validating/duration.cxx @@ -117,14 +117,21 @@ namespace xsde size_type t_pos = tmp.find ('T'); char* p; + char c; unsigned long ul; if (s[pos] == 'S') { need_t = true; - str_.truncate (pos); pos = rfind_delim (s, pos - 1); + c = s[pos + 1]; + + if (c < '0' || c > '9') + { + _schema_error (schema_error::invalid_duration_value); + return; + } set_errno (0); seconds_ = strtod (s + pos + 1, &p); @@ -139,9 +146,15 @@ namespace xsde if (s[pos] == 'M' && t_pos != ro_string::npos && t_pos < pos) { need_t = true; - str_.truncate (pos); pos = rfind_delim (s, pos - 1); + c = s[pos + 1]; + + if (c < '0' || c > '9') + { + _schema_error (schema_error::invalid_duration_value); + return; + } set_errno (0); ul = strtoul (s + pos + 1, &p, 10); @@ -158,9 +171,15 @@ namespace xsde if (s[pos] == 'H') { need_t = true; - str_.truncate (pos); pos = rfind_delim (s, pos - 1); + c = s[pos + 1]; + + if (c < '0' || c > '9') + { + _schema_error (schema_error::invalid_duration_value); + return; + } set_errno (0); ul = strtoul (s + pos + 1, &p, 10); @@ -197,6 +216,13 @@ namespace xsde { str_.truncate (pos); pos = rfind_delim (s, pos - 1); + c = s[pos + 1]; + + if (c < '0' || c > '9') + { + _schema_error (schema_error::invalid_duration_value); + return; + } set_errno (0); ul = strtoul (s + pos + 1, &p, 10); @@ -214,6 +240,13 @@ namespace xsde { str_.truncate (pos); pos = rfind_delim (s, pos - 1); + c = s[pos + 1]; + + if (c < '0' || c > '9') + { + _schema_error (schema_error::invalid_duration_value); + return; + } set_errno (0); ul = strtoul (s + pos + 1, &p, 10); @@ -231,6 +264,13 @@ namespace xsde { str_.truncate (pos); pos = rfind_delim (s, pos - 1); + c = s[pos + 1]; + + if (c < '0' || c > '9') + { + _schema_error (schema_error::invalid_duration_value); + return; + } set_errno (0); ul = strtoul (s + pos + 1, &p, 10); |