From: Chuck Lever Date: Tue, 14 Jul 2009 20:12:23 +0000 (-0400) Subject: getport: replace getnameinfo(NI_NUMERICHOST) with inet_ntop(3) X-Git-Tag: nfs-utils-1-2-1-rc2~29 X-Git-Url: https://git.decadent.org.uk/gitweb/?p=nfs-utils.git;a=commitdiff_plain;h=df5e6316f040f49065d2821c05d4673994d48d4c;hp=df5e6316f040f49065d2821c05d4673994d48d4c getport: replace getnameinfo(NI_NUMERICHOST) with inet_ntop(3) getnameinfo(3) with the NI_NUMERICHOST flag is used in support/nfs/getport.c to convert socket addresses to universal address strings. Older versions of glibc do not have getnameinfo(3), however. In order for nfs-utils to build on older systems we switch in legacy code via HAVE_GETNAMEINFO and use inet_ntoa(3). A problem with this is that we have to double our test matrix to be sure that both versions of these routines build and operate correctly. Another minor problem is that inet_ntoa(3) is officially deprecated. So let's always use a single implementation based on inet_ntop(3). Universal address strings do not support link-local / scope IDs, so we don't lose any functionality by using inet_ntop(3) here. This means we open code a bit of logic that is available in most modern versions of glibc, but in return we can use exactly the same code for all builds (on systems with getnameinfo(3) and without). An additional benefit is we can avoid using NI_MAXHOST for character buffers that live on the stack: it's 1025 bytes. Instead, INET6_ADDRSTRLEN is used, which is just 46 bytes, plus an additional eight bytes for the port information. We add beefier buffer overflow detection logic as well. Signed-off-by: Chuck Lever Signed-off-by: Steve Dickson ---