mirror of
https://git.yoctoproject.org/poky
synced 2026-04-23 09:32:17 +02:00
net-tools: lib/inet6.c:INET6_rresolve() - various fixes
Integrate the commit from a70c568b90
to fix a bug which causes the 'netstat -a' to print "[UNKNOWN]" in case of
DNS problem instead of IPv6 address.
(From OE-Core rev: e99a7220bbc2d605200d5005ba40bf45f6f8dcf5)
Signed-off-by: Jianchuan Wang <jianchuan.wang@windriver.com>
Signed-off-by: Ross Burton <ross.burton@intel.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -15,6 +15,7 @@ SRC_URI = "http://snapshot.debian.org/archive/debian/20050312T000000Z/pool/main/
|
||||
file://net-tools-1.60-sctp1.patch \
|
||||
file://net-tools-1.60-sctp2-quiet.patch \
|
||||
file://net-tools-1.60-sctp3-addrs.patch \
|
||||
file://0001-lib-inet6.c-INET6_rresolve-various-fixes.patch \
|
||||
"
|
||||
|
||||
# for this package we're mostly interested in tracking debian patches,
|
||||
|
||||
Reference in New Issue
Block a user