Skip negative integers in input framework where not type-permissible

Script-layer counts, when provided as negative integers in an input
file, got cast to unsigned values because strtoull() does not complain
about negative values. For example, input string "-1" would lead to
value 18446744073709551615 (an all-ones 64-bit int) on x86_64. This is
more likely to be an error than an intent to get very large,
platform-dependent values, so these input lines are now skipped with
according messaging in the reporter.log/stderr.

This also affected ports: -1/tcp got cast to unsigned and only thrown
out because PortVal rejects values > 65535, mapping them to 0. We now
skip such inputs as well.

Updates existing input framework tests to capture the new behavior.
This commit is contained in:
Christian Kreibich 2021-01-28 22:42:39 -08:00
parent d845f01b27
commit 38d6b6a98b
7 changed files with 25 additions and 7 deletions

View file

@ -4,6 +4,8 @@
# @TEST-EXEC: sed 1d .stderr > .stderrwithoutfirstline
# @TEST-EXEC: TEST_DIFF_CANONIFIER=$SCRIPTS/diff-remove-abspath btest-diff .stderrwithoutfirstline
# Note the tab+space separator in the last line of the following is
# intentional. It verifies our whitespace handling.
@TEST-START-FILE input.log
#separator \x09
#fields i c
@ -11,7 +13,7 @@
12129223372036854775800 121218446744073709551612
9223372036854775801TEXTHERE 1Justtext
Justtext 1
9223372036854775800 -18446744073709551612
9223372036854775800 -18446744073709551612
@TEST-END-FILE
redef exit_only_after_terminate = T;