summaryrefslogtreecommitdiffstats
path: root/meta/recipes-extended/net-tools/net-tools
diff options
context:
space:
mode:
authorShan Hai <shan.hai@windriver.com>2016-07-21 22:21:19 -0400
committerRichard Purdie <richard.purdie@linuxfoundation.org>2016-07-25 23:47:01 +0100
commite99a7220bbc2d605200d5005ba40bf45f6f8dcf5 (patch)
tree95e5e93cd82d290fee799ecc7ee84a7468a224dc /meta/recipes-extended/net-tools/net-tools
parent0d69b3bf6cdeee866642529b6269391146333a43 (diff)
downloadopenembedded-core-contrib-e99a7220bbc2d605200d5005ba40bf45f6f8dcf5.tar.gz
net-tools: lib/inet6.c:INET6_rresolve() - various fixes
Integrate the commit from https://github.com/ecki/net-tools/commit/a70c568b907d23ec2cf7defc81be50c351968f12 to fix a bug which causes the 'netstat -a' to print "[UNKNOWN]" in case of DNS problem instead of IPv6 address. Signed-off-by: Jianchuan Wang <jianchuan.wang@windriver.com> Signed-off-by: Ross Burton <ross.burton@intel.com>
Diffstat (limited to 'meta/recipes-extended/net-tools/net-tools')
-rw-r--r--meta/recipes-extended/net-tools/net-tools/0001-lib-inet6.c-INET6_rresolve-various-fixes.patch87
1 files changed, 87 insertions, 0 deletions
diff --git a/meta/recipes-extended/net-tools/net-tools/0001-lib-inet6.c-INET6_rresolve-various-fixes.patch b/meta/recipes-extended/net-tools/net-tools/0001-lib-inet6.c-INET6_rresolve-various-fixes.patch
new file mode 100644
index 0000000000..8be45ccac9
--- /dev/null
+++ b/meta/recipes-extended/net-tools/net-tools/0001-lib-inet6.c-INET6_rresolve-various-fixes.patch
@@ -0,0 +1,87 @@
+From 08abfcd923e9f37d1902db26771b1dc6731eb265 Mon Sep 17 00:00:00 2001
+From: Jiri Popelka <jpopelka@redhat.com>
+Date: Fri, 27 Sep 2013 18:40:06 +0200
+Subject: [PATCH 1/1] lib/inet6.c:INET6_rresolve() - various fixes
+
+1) Fall-back to numeric address if getnameinfo fails.
+ Reverse lookup is not mandatory, therefore its fail
+ is not an error. Just return numeric address in that case.
+ This makes netstat/route show IPv6 address instead of
+ [UNKNOWN] in case of DNS problems.
+
+2) Pass length of 'name' buffer into function.
+ 'name' is a pointer and therefore sizeof(name)
+ returns size of pointer and not size of the buffer.
+ see http://stackoverflow.com/questions/14298710/c-pointers-and-arrays-sizeof-operator
+ The sizeof() usage was added with commit 604785adc,
+ so I checked all the other changes in that commit
+ and they seem to be OK.
+
+3) remove unused 's' variable
+
+Upstream-Status: Pending
+
+Signed-off-by: Shan Hai <shan.hai@windriver.com>
+Signed-off-by: Jianchuan Wang <jianchuan.wang@windriver.com>
+---
+ lib/inet6.c | 21 ++++++++++-----------
+ 1 file changed, 10 insertions(+), 11 deletions(-)
+
+diff --git a/lib/inet6.c b/lib/inet6.c
+index 9a484a0..2a9c459 100644
+--- a/lib/inet6.c
++++ b/lib/inet6.c
+@@ -84,10 +84,9 @@ static int INET6_resolve(char *name, struct sockaddr_in6 *sin6)
+ #endif
+
+
+-static int INET6_rresolve(char *name, struct sockaddr_in6 *sin6, int numeric)
++static int INET6_rresolve(char *name, size_t namelen,
++ struct sockaddr_in6 *sin6, int numeric)
+ {
+- int s;
+-
+ /* Grmpf. -FvK */
+ if (sin6->sin6_family != AF_INET6) {
+ #ifdef DEBUG
+@@ -98,21 +97,20 @@ static int INET6_rresolve(char *name, struct sockaddr_in6 *sin6, int numeric)
+ return (-1);
+ }
+ if (numeric & 0x7FFF) {
+- inet_ntop( AF_INET6, &sin6->sin6_addr, name, 80);
++ inet_ntop( AF_INET6, &sin6->sin6_addr, name, namelen);
+ return (0);
+ }
+ if (IN6_IS_ADDR_UNSPECIFIED(&sin6->sin6_addr)) {
+ if (numeric & 0x8000)
+- strcpy(name, "default");
++ safe_strncpy(name, "default", namelen);
+ else
+- strcpy(name, "[::]");
++ safe_strncpy(name, "[::]", namelen);
+ return (0);
+ }
+
+- if ((s = getnameinfo((struct sockaddr *) sin6, sizeof(struct sockaddr_in6),
+- name, 255 /* !! */ , NULL, 0, 0))) {
+- fputs("getnameinfo failed\n", stderr);
+- return -1;
++ if (getnameinfo((struct sockaddr *) sin6, sizeof(struct sockaddr_in6),
++ name, namelen , NULL, 0, 0)) {
++ inet_ntop( AF_INET6, &sin6->sin6_addr, name, namelen);
+ }
+ return (0);
+ }
+@@ -143,7 +141,8 @@ static char *INET6_sprint(struct sockaddr *sap, int numeric)
+
+ if (sap->sa_family == 0xFFFF || sap->sa_family == 0)
+ return safe_strncpy(buff, _("[NONE SET]"), sizeof(buff));
+- if (INET6_rresolve(buff, (struct sockaddr_in6 *) sap, numeric) != 0)
++ if (INET6_rresolve(buff, sizeof(buff),
++ (struct sockaddr_in6 *) sap, numeric) != 0)
+ return safe_strncpy(buff, _("[UNKNOWN]"), sizeof(buff));
+ return (fix_v4_address(buff, &((struct sockaddr_in6 *)sap)->sin6_addr));
+ }
+--
+1.8.5.2.233.g932f7e4
+