diff options
author | Vasil Velichckov <vvvelichkov@gmail.com> | 2016-01-14 17:55:51 +0200 |
---|---|---|
committer | Anders Broman <a.broman58@gmail.com> | 2016-02-04 05:13:16 +0000 |
commit | d5c1449d1b7ae0a2a04e401f9015a516ba7201f9 (patch) | |
tree | b135127e4533399a59e5db30a7377ca73bc21992 | |
parent | f6ff90fed6b18af3885d2cd66452004977cbcf24 (diff) | |
download | wireshark-d5c1449d1b7ae0a2a04e401f9015a516ba7201f9.tar.gz wireshark-d5c1449d1b7ae0a2a04e401f9015a516ba7201f9.tar.bz2 wireshark-d5c1449d1b7ae0a2a04e401f9015a516ba7201f9.zip |
[text2pcap] Fix parsing of hash sign at the end of the line
Change-Id: I4ff1ef28aba353fd7548cb5c0603fc29479aa854
Reviewed-on: https://code.wireshark.org/review/13294
Reviewed-by: Anders Broman <a.broman58@gmail.com>
-rw-r--r-- | test/captures/text2pcap_hash_eol.txt | 10 | ||||
-rwxr-xr-x | test/suite-text2pcap.sh | 29 | ||||
-rw-r--r-- | text2pcap-scanner.l | 8 | ||||
-rw-r--r-- | ui/text_import_scanner.l | 8 |
4 files changed, 47 insertions, 8 deletions
diff --git a/test/captures/text2pcap_hash_eol.txt b/test/captures/text2pcap_hash_eol.txt new file mode 100644 index 0000000000..b7c6d2f62f --- /dev/null +++ b/test/captures/text2pcap_hash_eol.txt @@ -0,0 +1,10 @@ +2015-10-01 21:16:24.317453 127.0.0.1 -> 127.0.0.1 UDP 96 Source port: 36887 Destination port: 36888 + +0000 00 00 00 00 00 00 00 00 00 00 00 00 08 00 45 00 ..............E. +0010 00 3e 3b f2 40 00 40 11 00 bb 7f 00 00 01 7f 00 .>;.@.@......... +0020 00 01 90 17 90 18 00 2a 00 00 00 00 01 00 00 01 .......*........ +0030 00 00 00 00 00 00 01 01 01 01 01 01 01 01 20 23 .............. # +0040 01 01 01 01 01 01 01 01 01 01 01 01 01 01 01 01 ................ +0050 01 01 01 01 01 01 01 01 01 01 01 01 2f cc 9c e4 ............/... + +#TEXT2PCAP test_directive diff --git a/test/suite-text2pcap.sh b/test/suite-text2pcap.sh index 2f87c7b844..d987662b5f 100755 --- a/test/suite-text2pcap.sh +++ b/test/suite-text2pcap.sh @@ -82,6 +82,12 @@ text2pcap_common_check() { test_step_failed "text2pcap didn't complete" fi + grep -q "Inconsistent offset" testout.txt + if [ $? -eq 0 ]; then + cat ./testout.txt + test_step_failed "text2pcap detected inconsistent offset" + fi + text2pcap_capinfos "./testout.pcap" if [ ! $? -eq $EXIT_OK ]; then test_step_failed "text2pcap_capinfos return error" @@ -284,6 +290,28 @@ text2pcap_sip_pcapng_test() { text2pcap_basic_test "sip.pcapng" } +text2pcap_step_hash_at_eol() { + $TEXT2PCAP -n -d -t "%Y-%m-%d %H:%M:%S."\ + "${CAPTURE_DIR}/text2pcap_hash_eol.txt" testout.pcap > testout.txt 2>&1 + RETURNVALUE=$? + + grep -q "Inconsistent offset" testout.txt + if [ $? -eq 0 ]; then + cat ./testout.txt + test_step_failed "text2pcap failed to parse the hash sign at the end of the line" + fi + + #Check that #TEXT2PCAP is not prased as a comment + grep -q "Directive \[ test_directive" testout.txt + if [ $? -ne 0 ]; then + cat ./testout.txt + test_step_failed "text2pcap failed to parse #TEXT2PCAP test_directive" + fi + + text2pcap_common_pcapng_check $RETURNVALUE "Ethernet" 1 96 + test_step_ok +} + text2pcap_cleanup_step() { rm -f ./testin.txt rm -f ./testout.txt @@ -315,6 +343,7 @@ text2pcap_suite() { test_step_add "testing with dns+icmp.pcapng.gz" text2pcap_dns_icmp_pcapng_gz_test test_step_add "testing with packet-h2-14_headers.pcapng" text2pcap_packet_h2_14_headers_pcapng_test test_step_add "testing with sip.pcapng" text2pcap_sip_pcapng_test + test_step_add "hash sign at the end of the line" text2pcap_step_hash_at_eol } # diff --git a/text2pcap-scanner.l b/text2pcap-scanner.l index be68b1b71b..3c9f0b2498 100644 --- a/text2pcap-scanner.l +++ b/text2pcap-scanner.l @@ -71,8 +71,8 @@ %} hexdigit [0-9A-Fa-f] -directive #TEXT2PCAP.* -comment #[^W].* +directive ^#TEXT2PCAP.*\r?\n +comment ^[\t ]*#.*\r?\n byte [0-9A-Fa-f][0-9A-Fa-f][ \t] byte_eol [0-9A-Fa-f][0-9A-Fa-f]\r?\n offset [0-9A-Fa-f]+[: \t] @@ -90,6 +90,6 @@ eol \r?\n\r? {mailfwd}{offset} { parse_token(T_OFFSET, yytext+1); } {eol} { parse_token(T_EOL, NULL); } [ \t] ; /* ignore whitespace */ -{directive} { parse_token(T_DIRECTIVE, yytext); } -{comment} ; /* ignore comments */ +{directive} { parse_token(T_DIRECTIVE, yytext); parse_token(T_EOL, NULL); } +{comment} { parse_token(T_EOL, NULL); } {text} { parse_token(T_TEXT, yytext); } diff --git a/ui/text_import_scanner.l b/ui/text_import_scanner.l index 23e6d24adb..9af93643e4 100644 --- a/ui/text_import_scanner.l +++ b/ui/text_import_scanner.l @@ -73,8 +73,8 @@ %} hexdigit [0-9A-Fa-f] -directive #TEXT2PCAP.* -comment #[^W].* +directive ^#TEXT2PCAP.*\r?\n +comment ^[\t ]*#.*\r?\n byte [0-9A-Fa-f][0-9A-Fa-f][ \t] byte_eol [0-9A-Fa-f][0-9A-Fa-f]\r?\n offset [0-9A-Fa-f]+[: \t] @@ -92,8 +92,8 @@ eol \r?\n\r? {mailfwd}{offset} { parse_token(T_OFFSET, yytext+1); } {eol} { parse_token(T_EOL, NULL); } [ \t] ; /* ignore whitespace */ -{directive} { parse_token(T_DIRECTIVE, yytext); } -{comment} ; /* ignore comments */ +{directive} { parse_token(T_DIRECTIVE, yytext); parse_token(T_EOL, NULL); } +{comment} { parse_token(T_EOL, NULL); } {text} { parse_token(T_TEXT, yytext); } <<EOF>> { write_current_packet(); yyterminate(); } |