From: Michael Tremer Date: Wed, 23 Jan 2019 04:10:23 +0000 (+0000) Subject: xtables-addons: Fix generating GeoIP database X-Git-Tag: v2.21-core127~3 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=480e3014429820c687ceeb17a3ad0b46d2b6f2ed;p=ipfire-2.x.git 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 --- diff --git a/lfs/xtables-addons b/lfs/xtables-addons index 260820955a..4cf220c4e1 100644 --- a/lfs/xtables-addons +++ b/lfs/xtables-addons @@ -82,6 +82,8 @@ $(TARGET) : $(patsubst %,$(DIR_DL)/%,$(objects)) @$(PREBUILD) @rm -rf $(DIR_APP) && cd $(DIR_SRC) && tar axf $(DIR_DL)/$(DL_FILE) + cd $(DIR_APP) && patch -Np1 < $(DIR_SRC)/src/patches/xtables-addons-3.2-fix-database-generation.patch + # Only build the specified modules. cp -avf $(DIR_SRC)/config/xtables-addons/mconfig \ $(DIR_APP)/mconfig diff --git a/src/patches/xtables-addons-3.2-fix-database-generation.patch b/src/patches/xtables-addons-3.2-fix-database-generation.patch new file mode 100644 index 0000000000..5574e200d6 --- /dev/null +++ b/src/patches/xtables-addons-3.2-fix-database-generation.patch @@ -0,0 +1,18 @@ +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; + }