summaryrefslogtreecommitdiff
path: root/src/lib/libc/net/getnameinfo.3
diff options
context:
space:
mode:
Diffstat (limited to 'src/lib/libc/net/getnameinfo.3')
-rw-r--r--src/lib/libc/net/getnameinfo.316
1 files changed, 9 insertions, 7 deletions
diff --git a/src/lib/libc/net/getnameinfo.3 b/src/lib/libc/net/getnameinfo.3
index ccb46faece..b83b9d5079 100644
--- a/src/lib/libc/net/getnameinfo.3
+++ b/src/lib/libc/net/getnameinfo.3
@@ -1,4 +1,4 @@
1.\" $OpenBSD: getnameinfo.3,v 1.34 2004/12/21 01:01:47 itojun Exp $ 1.\" $OpenBSD: getnameinfo.3,v 1.35 2004/12/21 03:40:31 jaredy Exp $
2.\" 2.\"
3.\" Copyright (C) 2004 Internet Systems Consortium, Inc. ("ISC") 3.\" Copyright (C) 2004 Internet Systems Consortium, Inc. ("ISC")
4.\" Copyright (C) 2000, 2001 Internet Software Consortium. 4.\" Copyright (C) 2000, 2001 Internet Software Consortium.
@@ -26,7 +26,8 @@
26.Fd #include <sys/socket.h> 26.Fd #include <sys/socket.h>
27.Fd #include <netdb.h> 27.Fd #include <netdb.h>
28.Ft int 28.Ft int
29.Fn getnameinfo "const struct sockaddr *sa" "socklen_t salen" "char *host" "size_t hostlen" "char *serv" "size_t servlen" "int flags" 29.Fn getnameinfo "const struct sockaddr *sa" "socklen_t salen" "char *host" \
30 "size_t hostlen" "char *serv" "size_t servlen" "int flags"
30.Sh DESCRIPTION 31.Sh DESCRIPTION
31The 32The
32.Fn getnameinfo 33.Fn getnameinfo
@@ -68,7 +69,7 @@ The maximum value for
68is 69is
69.Dv NI_MAXHOST 70.Dv NI_MAXHOST
70and 71and
71the maximum value for 72the maximum value for
72.Fa servlen 73.Fa servlen
73is 74is
74.Dv NI_MAXSERV , 75.Dv NI_MAXSERV ,
@@ -95,7 +96,7 @@ instead of a host name.
95A name is required. 96A name is required.
96If the host name cannot be found in DNS and this flag is set, 97If the host name cannot be found in DNS and this flag is set,
97a non-zero error code is returned. 98a non-zero error code is returned.
98If the host name is not found and the flag is not set, the 99If the host name is not found and the flag is not set, the
99address is returned in numeric form. 100address is returned in numeric form.
100.It NI_NUMERICSERV 101.It NI_NUMERICSERV
101The service name is returned as a digit string representing the port number. 102The service name is returned as a digit string representing the port number.
@@ -107,7 +108,7 @@ to be called with a second argument of
107.Dq udp 108.Dq udp
108instead of its default of 109instead of its default of
109.Dq tcp . 110.Dq tcp .
110This is required for the few ports (512-514) that have different services 111This is required for the few ports (512\-514) that have different services
111for 112for
112.Tn UDP 113.Tn UDP
113and 114and
@@ -222,8 +223,9 @@ when it is actually
222.Pp 223.Pp
223To prevent such attacks, the use of 224To prevent such attacks, the use of
224.Dv NI_NAMEREQD 225.Dv NI_NAMEREQD
225is recommended when you use the result of 226is recommended when the result of
226.Fn getnameinfo 227.Fn getnameinfo
228is used
227for access control purposes: 229for access control purposes:
228.Bd -literal -offset indent 230.Bd -literal -offset indent
229struct sockaddr *sa; 231struct sockaddr *sa;
@@ -241,7 +243,7 @@ if (error == 0) {
241 if (getaddrinfo(addr, "0", &hints, &res) == 0) { 243 if (getaddrinfo(addr, "0", &hints, &res) == 0) {
242 /* malicious PTR record */ 244 /* malicious PTR record */
243 freeaddrinfo(res); 245 freeaddrinfo(res);
244 printf("bogus PTR record\\n"); 246 printf("bogus PTR record\en");
245 return -1; 247 return -1;
246 } 248 }
247 /* addr is FQDN as a result of PTR lookup */ 249 /* addr is FQDN as a result of PTR lookup */