summaryrefslogtreecommitdiffstats
path: root/mdk-stage1
diff options
context:
space:
mode:
authorThierry Vignaud <tv@mageia.org>2012-06-01 17:25:12 +0000
committerThierry Vignaud <tv@mageia.org>2012-06-01 17:25:12 +0000
commit678075ce42f671b1ca356800607172a8b36925c1 (patch)
treea7603d7f46e83639b3b26f5ea356cb7ffa3c00ba /mdk-stage1
parentc8efba7463a67209ecd1eae112e0ee7b437570fa (diff)
downloaddrakx-678075ce42f671b1ca356800607172a8b36925c1.tar
drakx-678075ce42f671b1ca356800607172a8b36925c1.tar.gz
drakx-678075ce42f671b1ca356800607172a8b36925c1.tar.bz2
drakx-678075ce42f671b1ca356800607172a8b36925c1.tar.xz
drakx-678075ce42f671b1ca356800607172a8b36925c1.zip
(mygethostbyaddr) switch from gethostbyaddr() to getnameinfo()
Diffstat (limited to 'mdk-stage1')
-rw-r--r--mdk-stage1/NEWS1
-rw-r--r--mdk-stage1/dns.c19
2 files changed, 12 insertions, 8 deletions
diff --git a/mdk-stage1/NEWS b/mdk-stage1/NEWS
index 0544949cb..e9eaabd8b 100644
--- a/mdk-stage1/NEWS
+++ b/mdk-stage1/NEWS
@@ -1,6 +1,7 @@
- do not advice long dead pcmcia.img & network.img images (mga#5466)
- first attempt at supporting XenBlk discs
- switch from gethostbyname() to getaddrinfo() (mga#4056)
+- switch from gethostbyaddr() to getnameinfo()
1.65
- load btrfs module to mount btrfs
diff --git a/mdk-stage1/dns.c b/mdk-stage1/dns.c
index 05f21a14a..488b4844e 100644
--- a/mdk-stage1/dns.c
+++ b/mdk-stage1/dns.c
@@ -75,19 +75,22 @@ int mygethostbyname(char * name, struct in_addr * addr)
char * mygethostbyaddr(char * ipnum)
{
- struct in_addr in;
- struct hostent * host;
+ struct sockaddr_in sa;
+ char hbuf[NI_MAXHOST];
/* prevent from timeouts */
if (_res.nscount == 0)
return NULL;
+
+ memset(&sa, 0, sizeof sa);
+ sa.sin_family = AF_INET;
- if (!inet_aton(ipnum, &in))
- return NULL;
- host = gethostbyaddr(&(in.s_addr), sizeof(in.s_addr) /* INADDRSZ */, AF_INET);
- if (host && host->h_name)
- return host->h_name;
- return NULL;
+ if (inet_pton(AF_INET, ipnum, &sa.sin_addr) != 1)
+ return NULL;
+
+ if (getnameinfo((struct sockaddr*)&sa, sizeof(sa), hbuf, sizeof(hbuf), NULL, 0, 0 |NI_NAMEREQD) == 0) //NI_NUMERICHOST NI_NAMEREQD
+ return strdup(hbuf);
+ else return NULL;
}
#elif defined(__GLIBC__)