freebsd-dev/ntpdc/nl.pl
Cy Schubert 873997f35a Vendor import ntp-4.2.8p3.
Approved by:	delphij (implicit, using SO hat)
Security:	VuXML: 0d0f3050-1f69-11e5-9ba9-d050996490d0
Security:	http://bugs.ntp.org/show_bug.cgi?id=2853
Security:	https://www.kb.cert.org/vuls/id/668167
Security:	http://support.ntp.org/bin/view/Main/SecurityNotice#June_2015_NTP_Security_Vulnerabi
2015-07-01 03:12:13 +00:00

44 lines
1.0 KiB
Perl
Executable File

#! /usr/local/bin/perl -w
$found = 0;
$last = 0;
$debug = 0;
while (<>) {
next if /^#/;
next if /^\s*$/;
if (/^typedef union req_data_u_tag/) {
$found = 1;
}
if (/^struct info_dns_assoc/) {
$last = 1;
}
if ($found) {
if (/^(struct\s*\w*)\s*{\s*$/) {
$type = $1;
print STDERR "type = '$type'\n" if $debug;
printf " printf(\"sizeof($type) = %%d\\n\", \n\t (int) sizeof($type));\n";
next;
}
if (/^typedef (union\s*\w*)\s*{\s*$/) {
$type = $1;
print STDERR "union = '$type'\n" if $debug;
printf " printf(\"sizeof($type) = %%d\\n\", \n\t (int) sizeof($type));\n";
next;
}
if (/\s*\w+\s+(\w*)\s*(\[.*\])?\s*;\s*$/) {
$field = $1;
print STDERR "\tfield = '$field'\n" if $debug;
printf " printf(\"offsetof($field) = %%d\\n\", \n\t (int) offsetof($type, $field));\n";
next;
}
if (/^}\s*\w*\s*;\s*$/) {
printf " printf(\"\\n\");\n\n";
$found = 0 if $last;
next;
}
print STDERR "Unmatched line: $_";
exit 1;
}
}