[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[SCM] GNU Inetutils branch, master, updated. inetutils-1_9_2-26-g8c7a55
From: |
Mats Erik Andersson |
Subject: |
[SCM] GNU Inetutils branch, master, updated. inetutils-1_9_2-26-g8c7a55e |
Date: |
Thu, 17 Jul 2014 22:56:21 +0000 |
This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "GNU Inetutils ".
The branch, master has been updated
via 8c7a55e6eb1b2d18561e4669e0a7b5a4aa8219ac (commit)
from faff170bbc56b2dbf7def54d2e69dc91a1b3b66e (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
http://git.savannah.gnu.org/cgit/inetutils.git/commit/?id=8c7a55e6eb1b2d18561e4669e0a7b5a4aa8219ac
commit 8c7a55e6eb1b2d18561e4669e0a7b5a4aa8219ac
Author: Mats Erik Andersson <address@hidden>
Date: Thu Jul 17 23:45:05 2014 +0200
Portability of canonical host name.
For a numerical host name, getaddrinfo() need not set
a value for `ai_canonname'. Protect against this.
Problem was uncovered by a system running OpenBSD 5.5.
diff --git a/ChangeLog b/ChangeLog
index 8d11784..926c36e 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,15 @@
+2014-07-17 Mats Erik Andersson <address@hidden>
+
+ Portability of canonical host name.
+ In response to a numerical address, getaddrinfo()
+ does not populate `ai_canonname' by necessity.
+
+ * ftp/ftp.c (hookup): Copy `RES->ai_canonname' only
+ if set. Copy from RHOST otherwise.
+ * ping/libping.c (ping_set_dest): Likewise; with P.
+ * ping/ping6.c (ping_set_dest): Likewise, with RHOST.
+ * src/traceroute.c (main): Likewise.
+
2014-07-16 Mats Erik Andersson <address@hidden>
Handle access timing in fractions of a second.
diff --git a/ftp/ftp.c b/ftp/ftp.c
index 17ddd28..d117974 100644
--- a/ftp/ftp.c
+++ b/ftp/ftp.c
@@ -169,9 +169,14 @@ hookup (char *host, int port)
free (rhost);
return ((char *) 0);
}
- free (rhost);
- strncpy (hostnamebuf, res->ai_canonname, sizeof (hostnamebuf));
+
+ if (res->ai_canonname)
+ strncpy (hostnamebuf, res->ai_canonname, sizeof (hostnamebuf));
+ else
+ strncpy (hostnamebuf, rhost, sizeof (hostnamebuf));
+
hostname = hostnamebuf;
+ free (rhost);
for (ai = res; ai != NULL; ai = ai->ai_next, ++again)
{
diff --git a/ping/libping.c b/ping/libping.c
index 01c8c7e..474cc68 100644
--- a/ping/libping.c
+++ b/ping/libping.c
@@ -291,15 +291,19 @@ ping_set_dest (PING * ping, char *host)
# endif
rc = getaddrinfo (p, NULL, &hints, &res);
-# ifdef HAVE_IDN
- free (p);
-# endif
if (rc)
return 1;
memcpy (&ping->ping_dest.ping_sockaddr, res->ai_addr, res->ai_addrlen);
- ping->ping_hostname = strdup (res->ai_canonname);
+ if (res->ai_canonname)
+ ping->ping_hostname = strdup (res->ai_canonname);
+ else
+ ping->ping_hostname = strdup (p);
+
+# ifdef HAVE_IDN
+ free (p);
+# endif
freeaddrinfo (res);
return 0;
diff --git a/ping/ping6.c b/ping/ping6.c
index cada992..a998d2b 100644
--- a/ping/ping6.c
+++ b/ping/ping6.c
@@ -1020,15 +1020,19 @@ ping_set_dest (PING * ping, char *host)
#endif
err = getaddrinfo (rhost, NULL, &hints, &result);
-#if HAVE_IDN
- free (rhost);
-#endif
if (err)
return 1;
memcpy (&ping->ping_dest.ping_sockaddr6, result->ai_addr,
result->ai_addrlen);
- ping->ping_hostname = strdup (result->ai_canonname);
+ if (result->ai_canonname)
+ ping->ping_hostname = strdup (result->ai_canonname);
+ else
+ ping->ping_hostname = strdup (rhost);
+
+#if HAVE_IDN
+ free (rhost);
+#endif
freeaddrinfo (result);
if (!ping->ping_hostname)
diff --git a/src/traceroute.c b/src/traceroute.c
index 81f4c6e..0410182 100644
--- a/src/traceroute.c
+++ b/src/traceroute.c
@@ -312,7 +312,6 @@ main (int argc, char **argv)
#endif
rc = getaddrinfo (rhost, NULL, &hints, &res);
- free (rhost);
if (rc)
error (EXIT_FAILURE, 0, "unknown host");
@@ -321,11 +320,13 @@ main (int argc, char **argv)
dest.sin_port = htons (opt_port);
getnameinfo (res->ai_addr, res->ai_addrlen, addrstr, sizeof (addrstr),
- NULL, 0, NI_NUMERICHOST);
+ NULL, 0, NI_NUMERICHOST);
printf ("traceroute to %s (%s), %d hops max\n",
- res->ai_canonname, addrstr, opt_max_hops);
+ res->ai_canonname ? res->ai_canonname : rhost,
+ addrstr, opt_max_hops);
+ free (rhost);
freeaddrinfo (res);
trace_ip_opts (&dest);
@@ -398,7 +399,7 @@ do_try (trace_t * trace, const int hop,
/* was interrupted */
break;
default:
- error (EXIT_FAILURE, errno, "select failed");
+ error (EXIT_FAILURE, errno, "select failed");
break;
}
}
@@ -494,16 +495,16 @@ trace_init (trace_t * t, const struct sockaddr_in to,
{
t->icmpfd = socket (PF_INET, SOCK_RAW, protocol->p_proto);
if (t->icmpfd < 0)
- error (EXIT_FAILURE, errno, "socket");
+ error (EXIT_FAILURE, errno, "socket");
if (setsockopt (t->icmpfd, IPPROTO_IP, IP_TTL,
ttlp, sizeof (*ttlp)) < 0)
- error (EXIT_FAILURE, errno, "setsockopt");
+ error (EXIT_FAILURE, errno, "setsockopt");
}
else
{
/* FIXME: Should we error out? */
- error (EXIT_FAILURE, 0, "can't find supplied protocol 'icmp'");
+ error (EXIT_FAILURE, 0, "can't find supplied protocol 'icmp'");
}
/* free (protocol); ??? */
@@ -672,12 +673,12 @@ trace_write (trace_t * t)
case ECONNRESET:
break;
default:
- error (EXIT_FAILURE, errno, "sendto");
+ error (EXIT_FAILURE, errno, "sendto");
}
}
if (gettimeofday (&t->tsent, NULL) < 0)
- error (EXIT_FAILURE, errno, "gettimeofday");
+ error (EXIT_FAILURE, errno, "gettimeofday");
}
break;
@@ -699,12 +700,12 @@ trace_write (trace_t * t)
case ECONNRESET:
break;
default:
- error (EXIT_FAILURE, errno, "sendto");
+ error (EXIT_FAILURE, errno, "sendto");
}
}
if (gettimeofday (&t->tsent, NULL) < 0)
- error (EXIT_FAILURE, errno, "gettimeofday");
+ error (EXIT_FAILURE, errno, "gettimeofday");
}
break;
-----------------------------------------------------------------------
Summary of changes:
ChangeLog | 12 ++++++++++++
ftp/ftp.c | 9 +++++++--
ping/libping.c | 12 ++++++++----
ping/ping6.c | 12 ++++++++----
src/traceroute.c | 23 ++++++++++++-----------
5 files changed, 47 insertions(+), 21 deletions(-)
hooks/post-receive
--
GNU Inetutils
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [SCM] GNU Inetutils branch, master, updated. inetutils-1_9_2-26-g8c7a55e,
Mats Erik Andersson <=