Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame^] | 1 | From 714e2b458c151c5bdfe93647445cd00dd8e36fff Mon Sep 17 00:00:00 2001 |
| 2 | From: Petr Vorel <petr.vorel@gmail.com> |
| 3 | Date: Sat, 21 Jul 2018 17:46:14 +0200 |
| 4 | Subject: [PATCH] ping: Fix AI_CANONIDN usage on some systems |
| 5 | |
| 6 | Upstream-Status: Backport |
| 7 | Signed-off-by: Ross Burton <ross.burton@intel.com> |
| 8 | |
| 9 | Commit 99f67db used AI_CANONIDN in a way, which broke compilation on |
| 10 | systems where AI_CANONIDN is not defined in netdb.h (e.g. glibc < 2.3.4, |
| 11 | alternative libcs that don't support IDN: e.g. current musl 1.1.19 and |
| 12 | uClibc-ng 1.0.30) when not using the system libidn2. |
| 13 | |
| 14 | Fixes: 99f67db ping: Fix ping name encoded using ACE on C locale |
| 15 | |
| 16 | Reported-by: Nicholas Fish |
| 17 | Signed-off-by: Petr Vorel <petr.vorel@gmail.com> |
| 18 | |
| 19 | --- |
| 20 | ping.c | 2 +- |
| 21 | ping.h | 2 +- |
| 22 | 2 files changed, 2 insertions(+), 2 deletions(-) |
| 23 | |
| 24 | diff --git a/ping.c b/ping.c |
| 25 | index 733477f..b241815 100644 |
| 26 | --- a/ping.c |
| 27 | +++ b/ping.c |
| 28 | @@ -207,9 +207,9 @@ main(int argc, char **argv) |
| 29 | |
| 30 | #ifdef USE_IDN |
| 31 | setlocale(LC_ALL, ""); |
| 32 | -#endif |
| 33 | if (!strcmp(setlocale(LC_ALL, NULL), "C")) |
| 34 | hints.ai_flags &= ~ AI_CANONIDN; |
| 35 | +#endif |
| 36 | |
| 37 | /* Support being called using `ping4` or `ping6` symlinks */ |
| 38 | if (argv[0][strlen(argv[0])-1] == '4') |
| 39 | diff --git a/ping.h b/ping.h |
| 40 | index 3e09685..8a0c4ef 100644 |
| 41 | --- a/ping.h |
| 42 | +++ b/ping.h |
| 43 | @@ -28,7 +28,6 @@ |
| 44 | #include <netinet/icmp6.h> |
| 45 | #include <linux/filter.h> |
| 46 | #include <resolv.h> |
| 47 | -#include <locale.h> |
| 48 | |
| 49 | #ifdef CAPABILITIES |
| 50 | #include <sys/prctl.h> |
| 51 | @@ -36,6 +35,7 @@ |
| 52 | #endif |
| 53 | |
| 54 | #ifdef USE_IDN |
| 55 | +#include <locale.h> |
| 56 | #include <idn2.h> |
| 57 | #define getaddrinfo_flags (AI_CANONNAME | AI_IDN | AI_CANONIDN) |
| 58 | #define getnameinfo_flags NI_IDN |