Fix out-of-bounds with military and truncated time zones; add more tests

Out-of-bounds was already covered by the fact that the date is appended 32
zero-bytes in ParseRFC822Date() as a safety measure. But now the time zone
parsing section of the function no longer relies on those extra zeros
being present.

Added tests for RFC822 timestamps with military time zones, and more types
of truncated, invalid time zone specifiers.
This commit is contained in:
Lauri Nurmi 2022-03-21 20:03:20 +02:00
parent 89eec3cb80
commit 770cf26afe
2 changed files with 37 additions and 5 deletions

View file

@ -1106,6 +1106,18 @@ void DateTimeTestCase::TestParseRFC822()
true
},
{
"Sat, 18 Dec 1999 10:48:30 G", // military time zone
{ 18, wxDateTime::Dec, 1999, 17, 48, 30 },
true
},
{
"Sat, 18 Dec 1999 10:48:30 Q", // military time zone
{ 18, wxDateTime::Dec, 1999, 6, 48, 30 },
true
},
// seconds are optional according to the RFC
{
"Sun, 01 Jun 2008 16:30 +0200",
@ -1159,12 +1171,30 @@ void DateTimeTestCase::TestParseRFC822()
false
},
{
"Sun, 01 Jun 2008 16:39:10 +020", // truncated time zone
{ 0 },
false
},
{
"Sun, 01 Jun 2008 16:39:10 +02", // truncated time zone
{ 0 },
false
},
{
"Sun, 01 Jun 2008 16:39:10 +0", // truncated time zone
{ 0 },
false
},
{
"Sun, 01 Jun 2008 16:39:10 +", // truncated time zone
{ 0 },
false
},
{
"Sun, 01 Jun 2008 16:39:10 GM", // truncated time zone
{ 0 },