mirror of
https://github.com/GothenburgBitFactory/timewarrior.git
synced 2025-06-26 10:54:28 +02:00
CLI: Ensure IDs are non-zero
This fixes out-of-bounds accesses in several subcommands when the invalid ID @0 is passed to the program.
This commit is contained in:
parent
9489ed5b70
commit
48aa9cfdc0
2 changed files with 6 additions and 1 deletions
|
@ -412,7 +412,8 @@ void CLI::identifyIds ()
|
|||
int digits;
|
||||
if (pig.skipLiteral ("@") &&
|
||||
pig.getDigits (digits) &&
|
||||
pig.eos ())
|
||||
pig.eos () &&
|
||||
digits > 0)
|
||||
{
|
||||
a.tag ("ID");
|
||||
a.attribute ("value", digits);
|
||||
|
|
|
@ -48,6 +48,10 @@ class TestIds(TestCase):
|
|||
self.assertIn(' @1 ', out)
|
||||
self.assertIn(' @2 ', out)
|
||||
|
||||
def test_should_fail_on_zero_id(self):
|
||||
code, out, err = self.t.runError("delete @0")
|
||||
self.assertIn("IDs must be specified.", err)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
from simpletap import TAPTestRunner
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue