commit-inetutils
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[SCM] GNU Inetutils branch, master, updated. inetutils-1_9_1-51-g05157b


From: Mats Erik Andersson
Subject: [SCM] GNU Inetutils branch, master, updated. inetutils-1_9_1-51-g05157b3
Date: Tue, 06 Mar 2012 22:52:41 +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  05157b367d15611f907d3070305f7ef6660802af (commit)
      from  383dbd669b7c7cb46ff83b6eba30da8a0be41ada (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=05157b367d15611f907d3070305f7ef6660802af


commit 05157b367d15611f907d3070305f7ef6660802af
Author: Mats Erik Andersson <address@hidden>
Date:   Tue Mar 6 23:41:07 2012 +0100

    ping,ping6: Host resolving issues.

diff --git a/ChangeLog b/ChangeLog
index b30632f..dc95090 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,13 @@
+2012-03-06  Mats Erik Andersson  <address@hidden>
+
+       * ping/ping6.c (print_echo): Use flag NI_NUMERICHOST in call
+       to getnameinfo() whenever the option OPT_NUMERIC is active.
+       * ping/ping_echo.c (ipaddr2str): Isolate case OPT_NUMERIC to
+       call xstrdup().  Then call xstrdup() if gethostbyaddr() fails.
+       In main body, replace every `hp->h_name' for `ipstr', and
+       conversely, since only `hp->h_name' can fail do be defined.
+       * tests/ping-localhost.sh: Insert option `-n' to ping and ping6.
+
 2012-03-03  Mats Erik Andersson <address@hidden>
 
        Display command prompt only in interactive mode.
diff --git a/ping/ping6.c b/ping/ping6.c
index 2ba519a..5647ded 100644
--- a/ping/ping6.c
+++ b/ping/ping6.c
@@ -521,8 +521,9 @@ print_echo (int dupflag, int hops, struct ping_stat 
*ping_stat,
       return 0;
     }
 
-  err = getnameinfo ((struct sockaddr *) from, sizeof (*from), buf,
-                    sizeof (buf), NULL, 0, 0);
+  err = getnameinfo ((struct sockaddr *) from, sizeof (*from),
+                    buf, sizeof (buf), NULL, 0,
+                    (options & OPT_NUMERIC) ? NI_NUMERICHOST : 0);
   if (err)
     {
       const char *errmsg;
diff --git a/ping/ping_echo.c b/ping/ping_echo.c
index 5d600b6..0278e35 100644
--- a/ping/ping_echo.c
+++ b/ping/ping_echo.c
@@ -197,23 +197,26 @@ ipaddr2str (struct in_addr ina)
 {
   struct hostent *hp;
 
-  if (options & OPT_NUMERIC
-      || !(hp = gethostbyaddr ((char *) &ina, 4, AF_INET)))
+  if (options & OPT_NUMERIC)
+    return xstrdup (inet_ntoa (ina));
+
+  hp = gethostbyaddr ((char *) &ina, sizeof (ina), AF_INET);
+  if (hp == NULL)
     return xstrdup (inet_ntoa (ina));
   else
     {
       char *ipstr = inet_ntoa (ina);
-      int len = strlen (hp->h_name) + 1;
+      int len = strlen (ipstr) + 1;
       char *buf;
 
-      if (ipstr)
-       len += strlen (ipstr) + 3;      /* a pair of parentheses and a space */
+      if (hp->h_name)
+       len += strlen (hp->h_name) + 3; /* a pair of parentheses and a space */
 
       buf = xmalloc (len);
-      if (ipstr)
+      if (hp->h_name)
        snprintf (buf, len, "%s (%s)", hp->h_name, ipstr);
       else
-       snprintf (buf, len, "%s", hp->h_name);
+       snprintf (buf, len, "%s", ipstr);
       return buf;
     }
 }
diff --git a/tests/ping-localhost.sh b/tests/ping-localhost.sh
index c78fa0f..2d29f26 100755
--- a/tests/ping-localhost.sh
+++ b/tests/ping-localhost.sh
@@ -47,11 +47,11 @@ fi
 errno=0
 errno2=0
 
-$PING -c 1 $TARGET || errno=$?
+$PING -n -c 1 $TARGET || errno=$?
 test $errno -eq 0 || echo "Failed at pinging $TARGET." >&2
 
 # Host might not have been built with IPv6 support..
-test -x $PING6 && $PING6 -c 1 $TARGET6 || errno2=$?
+test -x $PING6 && $PING6 -n -c 1 $TARGET6 || errno2=$?
 test $errno2 -eq 0 || echo "Failed at pinging $TARGET6." >&2
 
 test $errno -eq 0 || exit $errno

-----------------------------------------------------------------------

Summary of changes:
 ChangeLog               |   10 ++++++++++
 ping/ping6.c            |    5 +++--
 ping/ping_echo.c        |   17 ++++++++++-------
 tests/ping-localhost.sh |    4 ++--
 4 files changed, 25 insertions(+), 11 deletions(-)


hooks/post-receive
-- 
GNU Inetutils 



reply via email to

[Prev in Thread] Current Thread [Next in Thread]