aboutsummaryrefslogtreecommitdiffstats
path: root/tools
diff options
context:
space:
mode:
authorPeter Wu <peter@lekensteyn.nl>2018-09-20 00:23:14 +0200
committerAnders Broman <a.broman58@gmail.com>2018-09-20 23:01:03 +0000
commit1a63f1ca9b7e8c24b9a20373bd28e82f7181c368 (patch)
treeec7c0c8c2c1deab3527422478b92929f3e06907f /tools
parent54f106fb9cc529fe9a838582906a023eb8d903f2 (diff)
checkAPIs.pl: improve value_string validation in field definitions
Use of 32-bit value_string for 64-bit fields currently results in a runtime error during use, better catch it earlier. Use of 64-bit val64_string without BASE_VAL64_STRING will probably crash. Since many dissectors use no macro for value_string_ext, accept both VALS_EXT_PTR(x) and &x forms. Change-Id: I59a3f67425e7c00bdd54cbffd91e498ee0b078cd Reviewed-on: https://code.wireshark.org/review/29756 Petri-Dish: Alexis La Goutte <alexis.lagoutte@gmail.com> Tested-by: Petri Dish Buildbot Reviewed-by: Anders Broman <a.broman58@gmail.com>
Diffstat (limited to 'tools')
-rwxr-xr-xtools/checkAPIs.pl22
1 files changed, 18 insertions, 4 deletions
diff --git a/tools/checkAPIs.pl b/tools/checkAPIs.pl
index 6427eddf15..384df1a5d4 100755
--- a/tools/checkAPIs.pl
+++ b/tools/checkAPIs.pl
@@ -769,6 +769,8 @@ sub check_hf_entries($$)
$display =~ s/\s+//g;
$convert =~ s/\s+//g;
+ # GET_VALS_EXTP is a macro in packet-mq.h for packet-mq.c and packet-mq-pcf.c
+ $convert =~ s/\bGET_VALS_EXTP\(/VALS_EXT_PTR\(/;
#print "name=$name, abbrev=$abbrev, ft=$ft, display=$display, convert=>$convert<, bitmask=$bitmask, blurb=$blurb\n";
@@ -836,12 +838,24 @@ sub check_hf_entries($$)
print STDERR "Error: $hf uses RVALS but 'display' does not include BASE_RANGE_STRING in $filename\n";
$errorCount++;
}
- if ($convert =~ m/^VALS\(&.*\)/) {
- print STDERR "Error: $hf is passing the address of a pointer to VALS in $filename\n";
+ if ($convert =~ m/VALS64/ && $display !~ m/BASE_VAL64_STRING/) {
+ print STDERR "Error: $hf uses VALS64 but 'display' does not include BASE_VAL64_STRING in $filename\n";
$errorCount++;
}
- if ($convert =~ m/^RVALS\(&.*\)/) {
- print STDERR "Error: $hf is passing the address of a pointer to RVALS in $filename\n";
+ if ($display =~ /BASE_EXT_STRING/ && $convert !~ /^(VALS_EXT_PTR\(|&)/) {
+ print STDERR "Error: $hf: BASE_EXT_STRING should use VALS_EXT_PTR for 'strings' instead of '$convert' in $filename\n";
+ $errorCount++;
+ }
+ if ($ft =~ m/^FT_U?INT(8|16|24|32)$/ && $convert =~ m/^VALS64\(/) {
+ print STDERR "Error: $hf: 32-bit field must use VALS instead of VALS64 in $filename\n";
+ $errorCount++;
+ }
+ if ($ft =~ m/^FT_U?INT(40|48|56|64)$/ && $convert =~ m/^VALS\(/) {
+ print STDERR "Error: $hf: 64-bit field must use VALS64 instead of VALS in $filename\n";
+ $errorCount++;
+ }
+ if ($convert =~ m/^(VALS|VALS64|RVALS)\(&.*\)/) {
+ print STDERR "Error: $hf is passing the address of a pointer to $1 in $filename\n";
$errorCount++;
}
if ($convert !~ m/^((0[xX]0?)?0$|NULL$|VALS|VALS64|VALS_EXT_PTR|RVALS|TFS|CF_FUNC|FRAMENUM_TYPE|&|STRINGS_ENTERPRISES)/ && $display !~ /BASE_CUSTOM/) {