diff options
author | Lionel Elie Mamane <lionel@mamane.lu> | 2013-06-27 19:47:02 +0200 |
---|---|---|
committer | Fridrich Strba <fridrich@documentfoundation.org> | 2013-06-28 12:30:04 +0000 |
commit | 8fb464bc100bc0c8190a3147db1939df37f42929 (patch) | |
tree | 93b39cede2ebd217c1e1fa1c43db72a02c10575b /unotools | |
parent | f4fcf5464c249fe15d5e8d3dd09df8b377bcd559 (diff) |
fix crash when parsing empty string
the parsing of the hours would succeed, but the parsing of the minutes would access past-the-end of the string.
Probably same crash when parsing HH or HHMM formats.
Change-Id: I248810e5c4c425186f33e573634883263caff312
Reviewed-on: https://gerrit.libreoffice.org/4591
Reviewed-by: Fridrich Strba <fridrich@documentfoundation.org>
Tested-by: Fridrich Strba <fridrich@documentfoundation.org>
Diffstat (limited to 'unotools')
-rw-r--r-- | unotools/source/misc/datetime.cxx | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/unotools/source/misc/datetime.cxx b/unotools/source/misc/datetime.cxx index 93f60a6e007e..b383dc587709 100644 --- a/unotools/source/misc/datetime.cxx +++ b/unotools/source/misc/datetime.cxx @@ -424,8 +424,11 @@ bool ISO8601parseTime(const OUString &aTimeStr, starutil::Time& rTime) } goto end; } + if(n >= aTimeStr.getLength()) + goto end; } } + // minutes if (bSuccess && (bSuccess = getISO8601TimeToken(aTimeStr, n, tokInt, bFrac, tokFrac))) { @@ -452,12 +455,14 @@ bool ISO8601parseTime(const OUString &aTimeStr, starutil::Time& rTime) } goto end; } + if(n >= aTimeStr.getLength()) + goto end; } } // seconds if (bSuccess && (bSuccess = getISO8601TimeToken(aTimeStr, n, tokInt, bFrac, tokFrac))) { - if ( bFrac && n < aTimeStr.getLength()) + if (n < aTimeStr.getLength()) // junk after ISO time bSuccess = false; // max 60 for leap seconds |