bin: detect overflows in conversion functions

* bin/common_conv.cc (to_int, to_unsigned): Here.
* bin/common_range.cc (parse_range): And there.
* tests/core/ltlgrind.test, tests/core/genaut.test,
tests/core/randaut.test: Add test cases.
This commit is contained in:
Alexandre Duret-Lutz 2023-01-05 23:43:31 +01:00
parent 05edab3f5a
commit 96c3972c5c
5 changed files with 41 additions and 17 deletions

View file

@ -1,7 +1,7 @@
#!/bin/sh
# -*- coding: utf-8 -*-
# Copyright (C) 2017, 2018, 2019, 2020 Laboratoire de Recherche et Développement
# de l'Epita (LRDE).
# Copyright (C) 2017-2020, 2023 Laboratoire de Recherche et
# Développement de l'Epita (LRDE).
#
# This file is part of Spot, a model checking library.
#
@ -60,7 +60,10 @@ genaut --l-nba='1..3?' 2>err && exit 1
grep 'invalid range.*trailing garbage' err
genaut --l-nba='1..' 2>err && exit 1
grep 'invalid range.*missing end' err
genaut --l-nba='9999999999999999999999999..' 2>err && exit 1
grep 'start.*too large' err
genaut --l-nba='1..9999999999999999999999999' 2>err && exit 1
grep 'end.*too large' err
# Tests for autfilt -N/--nth
genaut --ks-nca=1..5 | autfilt -N 2..4 > range1.hoa

View file

@ -1,6 +1,6 @@
#! /bin/sh
# -*- coding: utf-8 -*-
# Copyright (C) 2014, 2015, 2019 Laboratoire de Recherche et Développement
# Copyright (C) 2014, 2015, 2019, 2023 Laboratoire de Recherche et Développement
# de l'Epita (LRDE).
#
# This file is part of Spot, a model checking library.
@ -198,3 +198,6 @@ checkopt_noparse -F input/2 --format '%<,%f,%>,%F,%L' <<EOF
1,0,3,input,1
1,1,3,input,1
EOF
ltlgrind -f 'a U b' -m 999999999999999999999999999 2>err && exit 1
grep 'too large' err

View file

@ -1,7 +1,7 @@
#!/bin/sh
# -*- coding: utf-8 -*-
# Copyright (C) 2014-2018, 2020, 2022 Laboratoire de Recherche et
# Développement de l'Epita (LRDE).
# Copyright (C) 2014-2018, 2020, 2022, 2023 Laboratoire de Recherche
# et Développement de l'Epita (LRDE).
#
# This file is part of Spot, a model checking library.
#
@ -29,6 +29,9 @@ grep "randaut: 3.1.*is not between 0 and 1 (in argument of -e" err
randaut -n1a 3 2>err && exit 1
grep "randaut: failed to parse '1a' as an integer.* -n/--automata)" err
randaut -n99999999999999999999999999 3 2>err && exit 1
grep "randaut:.*too large" err
randaut --spin -Q4 a b | ../ikwiad -H -XN - >out
grep 'States: 4' out
grep 'AP: 2' out