Fix validation of geofeeds with IPv6 networks
upstream commit c0ef630c7868e5b5647a4c05a54a1ed303081a0b
Marco d'Itri
1 year, 4 months ago
0 | diff --git a/compat/Makefile.am b/compat/Makefile.am | |
1 | index 66e97ad..34f35fd 100644 | |
2 | --- a/compat/Makefile.am | |
3 | +++ b/compat/Makefile.am | |
4 | @@ -46,6 +46,9 @@ endif | |
5 | if !HAVE_INET_NET_PTON | |
6 | libcompat_la_SOURCES += inet_net_pton.c | |
7 | endif | |
8 | +if BROKEN_INET_NET_PTON | |
9 | +libcompat_la_SOURCES += inet_net_pton.c | |
10 | +endif | |
11 | ||
12 | if !HAVE_PIPE2 | |
13 | libcompat_la_SOURCES += pipe2.c | |
14 | diff --git a/configure.ac b/configure.ac | |
15 | index ee4a736..bdbde80 100644 | |
16 | --- a/configure.ac | |
17 | +++ b/configure.ac | |
18 | @@ -236,6 +236,32 @@ AC_CHECK_FUNCS([ibuf_open]) | |
19 | # check functions that are expected to be in libresolv | |
20 | AC_SEARCH_LIBS([inet_net_pton],[resolv]) | |
21 | AC_CHECK_FUNCS([inet_net_pton]) | |
22 | +# check if inet_net_pton code can be used | |
23 | +if test "x$ac_cv_func_inet_net_pton" = "xyes"; then | |
24 | + AC_MSG_CHECKING([for working inet_net_pton]) | |
25 | + AC_RUN_IFELSE( | |
26 | + [AC_LANG_PROGRAM([[ | |
27 | +#include <sys/socket.h> | |
28 | +#include <netinet/in.h> | |
29 | +#include <arpa/inet.h> | |
30 | +#include <stdlib.h> | |
31 | + ]], [[ | |
32 | + struct in_addr ia; | |
33 | + struct in6_addr ia6; | |
34 | + | |
35 | + if (inet_net_pton(AF_INET, "192.0.2.0/24", &ia, sizeof(ia)) != 24) | |
36 | + exit(1); | |
37 | + if (inet_net_pton(AF_INET6, "2001:db8::/32", &ia6, sizeof(ia6)) != 32) | |
38 | + exit(1); | |
39 | + exit(0); | |
40 | + ]])], | |
41 | + [AC_MSG_RESULT([yes])], | |
42 | + [AC_MSG_RESULT([no]) | |
43 | + ac_cv_broken_inet_net_pton="yes" ], | |
44 | + [AC_MSG_WARN([cross compiling: assuming broken]) | |
45 | + ac_cv_broken_inet_net_pton="yes" ] | |
46 | + ) | |
47 | +fi | |
48 | ||
49 | # check functions that may be in different libs on other systems | |
50 | AC_SEARCH_LIBS([fts_open],[fts]) | |
51 | @@ -260,6 +286,8 @@ AM_CONDITIONAL([HAVE_GETDTABLECOUNT], [test "x$ac_cv_func_getdtablecount" = xyes | |
52 | AM_CONDITIONAL([HAVE_PIPE2], [test "x$ac_cv_func_pipe2" = xyes]) | |
53 | AM_CONDITIONAL([HAVE_PPOLL], [test "x$ac_cv_func_ppoll" = xyes]) | |
54 | AM_CONDITIONAL([HAVE_INET_NET_PTON], [test "x$ac_cv_func_inet_net_pton" = xyes]) | |
55 | +AM_CONDITIONAL([BROKEN_INET_NET_PTON], [test "x$ac_cv_broken_inet_net_pton" = xyes]) | |
56 | + | |
57 | AM_CONDITIONAL([HAVE_STRNVIS], [test "x$ac_cv_func_strnvis" = xyes]) | |
58 | AM_CONDITIONAL([BROKEN_STRNVIS], [test "x$ac_cv_broken_strnvis" = xyes]) | |
59 | AM_CONDITIONAL([HAVE_IMSG], [test "x$ac_cv_func_ibuf_open" = xyes]) |