Author: jlh
Date: Wed Oct  9 20:01:23 2019
New Revision: 353364
URL: https://svnweb.freebsd.org/changeset/base/353364

Log:
  Use inet_ntop(3) instead of inet_ntoa(3) for AF_INET socket details.
  
  This also makes the code closer to the one used for AF_INET6.

Modified:
  head/usr.bin/procstat/procstat_files.c

Modified: head/usr.bin/procstat/procstat_files.c
==============================================================================
--- head/usr.bin/procstat/procstat_files.c      Wed Oct  9 19:51:41 2019        
(r353363)
+++ head/usr.bin/procstat/procstat_files.c      Wed Oct  9 20:01:23 2019        
(r353364)
@@ -106,8 +106,13 @@ addr_to_string(struct sockaddr_storage *ss, char *buff
 
        case AF_INET:
                sin = (struct sockaddr_in *)ss;
-               snprintf(buffer, buflen, "%s:%d", inet_ntoa(sin->sin_addr),
-                   ntohs(sin->sin_port));
+               if (IS_INADDR_ANY(sin->sin_addr))
+                   snprintf(buffer, buflen, "%s:%d", "*",
+                       ntohs(sin->sin_port));
+               else if (inet_ntop(AF_INET, &sin->sin_addr, buffer2,
+                   sizeof(buffer2)) != NULL)
+                       snprintf(buffer, buflen, "%s:%d", buffer2,
+                           ntohs(sin->sin_port));
                break;
 
        case AF_INET6:
_______________________________________________
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"

Reply via email to