aboutsummaryrefslogtreecommitdiffstats
path: root/text2pcap-scanner.l
diff options
context:
space:
mode:
authorPeter Wu <peter@lekensteyn.nl>2018-10-13 00:21:16 +0200
committerAnders Broman <a.broman58@gmail.com>2018-10-13 05:16:22 +0000
commit22cf80d30d7310554f7b144a31cbdd14451a6d27 (patch)
tree511951b4b047cad7c5ffcd11c0a25b7297b22fba /text2pcap-scanner.l
parent9b72da0cdd7d2cd39f0a50defa5a08ada955e60b (diff)
text2pcap: gracefully handle hexdump without trailing LF
When copying hexdumps, the newline might be missing which would result in a capture file missing one byte in its packet. Adjust the grammar to recognize the two trailing hexadecimal characters as a "byte". This is safe because Flex picks the rule that matches the longest input string. So given "01 ", it will always match all three characters. If something like "01x" is given, then the "text" rule will be matched (as before). Only if no more characters are available (such as at the end of a file), then the rule will match two hexdigits. Remove the unnecessary hexdigit rule while at it. Change-Id: I21dc37d684d1c410ce720cb27706a6e54f87f94d Reviewed-on: https://code.wireshark.org/review/30190 Petri-Dish: Peter Wu <peter@lekensteyn.nl> Tested-by: Petri Dish Buildbot Reviewed-by: Anders Broman <a.broman58@gmail.com>
Diffstat (limited to 'text2pcap-scanner.l')
-rw-r--r--text2pcap-scanner.l3
1 files changed, 1 insertions, 2 deletions
diff --git a/text2pcap-scanner.l b/text2pcap-scanner.l
index f1ef1241fb..3a69a83ba1 100644
--- a/text2pcap-scanner.l
+++ b/text2pcap-scanner.l
@@ -68,10 +68,9 @@ DIAG_OFF_FLEX
%}
-hexdigit [0-9A-Fa-f]
directive ^#TEXT2PCAP.*\r?\n
comment ^[\t ]*#.*\r?\n
-byte [0-9A-Fa-f][0-9A-Fa-f][ \t]
+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]
offset_eol [0-9A-Fa-f]+\r?\n