GH-1245: require TLD of hostname literals to start with a letter

This commit is contained in:
Jon Siwek 2020-10-23 14:17:10 -07:00
parent 06191390c3
commit fb85a19fa8
4 changed files with 16 additions and 1 deletions

View file

@ -142,6 +142,7 @@ FILE [^ \t\n]+
PREFIX [^ \t\n]+
FLOAT (({D}*"."?{D})|({D}"."?{D}*))([eE][-+]?{D})?
H [A-Za-z0-9][A-Za-z0-9\-]*
HTLD [A-Za-z][A-Za-z0-9\-]*
ESCSEQ (\\([^\n]|[0-7]+|x[[:xdigit:]]+))
%%
@ -502,7 +503,7 @@ F RET_CONST(zeek::val_mgr->False()->Ref())
"0x"{HEX}+ RET_CONST(zeek::val_mgr->Count(static_cast<bro_uint_t>(strtoull(yytext, 0, 16))).release())
{H}("."{H})+ RET_CONST(zeek::detail::dns_mgr->LookupHost(yytext).release())
({H}".")+{HTLD} RET_CONST(zeek::detail::dns_mgr->LookupHost(yytext).release())
\"([^\\\n\"]|{ESCSEQ})*\" {
const char* text = yytext;

View file

@ -0,0 +1,2 @@
### BTest baseline data generated by btest-diff. Do not edit. Use "btest -U/-u" to update. Requires BTest >= 0.63.
error in <...>/invalid-hostnames.zeek, line 4: syntax error, at or near "f"

View file

@ -0,0 +1,2 @@
### BTest baseline data generated by btest-diff. Do not edit. Use "btest -U/-u" to update. Requires BTest >= 0.63.
error in <...>/invalid-hostnames.zeek, line 4: unknown identifier print0, at or near "print0"

View file

@ -0,0 +1,10 @@
# @TEST-EXEC-FAIL: zeek -b %INPUT >out 2>&1
# @TEST-EXEC: TEST_DIFF_CANONIFIER=$SCRIPTS/diff-remove-abspath btest-diff out
print0.0000000000005;
# @TEST-START-NEXT
# This is not a floating-point literal (like you'd see in C/C++) and it's
# also not a valid hostname since the TLD does not start with a letter.
print 0.05f;