TI-64: Command 'stop' with date before current interval's start date causes segfault

- Show error message if stop date is before current interval's start date
- Add test for this use case
This commit is contained in:
Thomas Lauf 2017-02-09 09:18:55 +01:00 committed by Paul Beckingham
parent 403b1c6f5e
commit e505129d5c
2 changed files with 11 additions and 0 deletions

View file

@ -62,7 +62,12 @@ int CmdStop (
// If a stop date is specified (and occupies filter.range.start) then use // If a stop date is specified (and occupies filter.range.start) then use
// that instead of the current time. // that instead of the current time.
if (filter.range.start.toEpoch () != 0) if (filter.range.start.toEpoch () != 0)
{
if (modified.range.start >= filter.range.start)
throw std::string ("The end of a date range must be after the start.");
modified.range.end = filter.range.start; modified.range.end = filter.range.start;
}
else else
modified.range.end = Datetime (); modified.range.end = Datetime ();

View file

@ -65,6 +65,12 @@ class TestStop(TestCase):
self.assertIn('0100Z', j[0]['start']) self.assertIn('0100Z', j[0]['start'])
self.assertIn('0200Z', j[0]['end']) self.assertIn('0200Z', j[0]['end'])
def test_invalid_stop(self):
"""Verify stop date after start date is an error"""
self.t("start 20160516T100200")
code, out, err = self.t.runError("stop 20160516T090100")
self.assertIn("The end of a date range must be after the start.", err)
def test_stop_all(self): def test_stop_all(self):
"""Start three tags, stop""" """Start three tags, stop"""
self.t("start 5mins ago one two three") self.t("start 5mins ago one two three")