Files
bpfire/src/patches/xtables-addons-3.2-fix-database-generation.patch
Michael Tremer 480e301442 xtables-addons: Fix generating GeoIP database
Perl seems to have a very funny feature where you cannot rely on
how it formats IP addresses into a binary string.

This seems to be 16 bytes long for IPv4 addresses when we (and the kernel)
only expect 4.

This patch changes this so that the last 12 bytes are just being dropped.

Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
2019-01-23 04:12:41 +00:00

19 lines
477 B
Diff

diff --git a/geoip/xt_geoip_build b/geoip/xt_geoip_build
index 3b15875..7bc42f3 100755
--- a/geoip/xt_geoip_build
+++ b/geoip/xt_geoip_build
@@ -259,7 +259,12 @@ sub writeCountry
my ($start, $end) = split('-', $range);
$start = inet_pton($family, $start);
$end = inet_pton($family, $end);
- print $fh $start, $end;
+
+ if ($family == AF_INET) {
+ print $fh substr($start, 0, 4), substr($end, 0, 4);
+ } else {
+ print $fh $start, $end;
+ }
}
close $fh;
}