mirror of
https://sourceware.org/git/glibc.git
synced 2025-01-05 09:01:07 +00:00
Update.
2004-03-13 Ulrich Drepper <drepper@redhat.com> * resolv/netdb.h (EAI_OVERFLOW): Define. (NI_IDN): Define. * inet/getnameinfo.c (getnameinfo): Return error in case argument buffers overflow. Implement NI_IDN. 2004-03-12 Ulrich Drepper <drepper@redhat.com> * resolv/netdb.h: Define AI_CANONIDN. * sysdeps/posix/getaddrinfo.c: Implement AI_CANONIDN.
This commit is contained in:
parent
d0b23069f7
commit
ab0fcbfaaa
12
ChangeLog
12
ChangeLog
@ -1,3 +1,15 @@
|
|||||||
|
2004-03-13 Ulrich Drepper <drepper@redhat.com>
|
||||||
|
|
||||||
|
* resolv/netdb.h (EAI_OVERFLOW): Define.
|
||||||
|
(NI_IDN): Define.
|
||||||
|
* inet/getnameinfo.c (getnameinfo): Return error in case argument
|
||||||
|
buffers overflow. Implement NI_IDN.
|
||||||
|
|
||||||
|
2004-03-12 Ulrich Drepper <drepper@redhat.com>
|
||||||
|
|
||||||
|
* resolv/netdb.h: Define AI_CANONIDN.
|
||||||
|
* sysdeps/posix/getaddrinfo.c: Implement AI_CANONIDN.
|
||||||
|
|
||||||
2004-03-12 Richard Henderson <rth@redhat.com>
|
2004-03-12 Richard Henderson <rth@redhat.com>
|
||||||
|
|
||||||
* sysdeps/unix/sysv/linux/alpha/select.S: Fix unwind. Propagate
|
* sysdeps/unix/sysv/linux/alpha/select.S: Fix unwind. Propagate
|
||||||
|
@ -51,6 +51,12 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|||||||
#include <sys/utsname.h>
|
#include <sys/utsname.h>
|
||||||
#include <bits/libc-lock.h>
|
#include <bits/libc-lock.h>
|
||||||
|
|
||||||
|
#ifdef HAVE_LIBIDN
|
||||||
|
# include <libidn/idna.h>
|
||||||
|
extern int __idna_to_unicode_lzlz (const char *input, char **output,
|
||||||
|
int flags);
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifndef min
|
#ifndef min
|
||||||
# define min(x,y) (((x) > (y)) ? (y) : (x))
|
# define min(x,y) (((x) > (y)) ? (y) : (x))
|
||||||
#endif /* min */
|
#endif /* min */
|
||||||
@ -160,7 +166,11 @@ getnameinfo (const struct sockaddr *sa, socklen_t addrlen, char *host,
|
|||||||
struct hostent th;
|
struct hostent th;
|
||||||
int ok = 0;
|
int ok = 0;
|
||||||
|
|
||||||
if (flags & ~(NI_NUMERICHOST|NI_NUMERICSERV|NI_NOFQDN|NI_NAMEREQD|NI_DGRAM))
|
if (flags & ~(NI_NUMERICHOST|NI_NUMERICSERV|NI_NOFQDN|NI_NAMEREQD|NI_DGRAM
|
||||||
|
#ifdef HAVE_LIBIDN
|
||||||
|
|NI_IDN
|
||||||
|
#endif
|
||||||
|
))
|
||||||
return EAI_BADFLAGS;
|
return EAI_BADFLAGS;
|
||||||
|
|
||||||
if (sa == NULL || addrlen < sizeof (sa_family_t))
|
if (sa == NULL || addrlen < sizeof (sa_family_t))
|
||||||
@ -244,18 +254,39 @@ getnameinfo (const struct sockaddr *sa, socklen_t addrlen, char *host,
|
|||||||
&& (c = nrl_domainname ())
|
&& (c = nrl_domainname ())
|
||||||
&& (c = strstr (h->h_name, c))
|
&& (c = strstr (h->h_name, c))
|
||||||
&& (c != h->h_name) && (*(--c) == '.'))
|
&& (c != h->h_name) && (*(--c) == '.'))
|
||||||
|
/* Terminate the string after the prefix. */
|
||||||
|
*c = '\0';
|
||||||
|
|
||||||
|
#ifdef HAVE_LIBIDN
|
||||||
|
/* If requested, convert from the IDN format. */
|
||||||
|
if (flags & NI_IDN)
|
||||||
{
|
{
|
||||||
strncpy (host, h->h_name,
|
char *out;
|
||||||
min(hostlen, (size_t) (c - h->h_name)));
|
int rc = __idna_to_unicode_lzlz (h->h_name, &out, 0);
|
||||||
host[min(hostlen - 1, (size_t) (c - h->h_name))]
|
if (rc != IDNA_SUCCESS)
|
||||||
= '\0';
|
{
|
||||||
ok = 1;
|
if (rc == IDNA_MALLOC_ERROR)
|
||||||
}
|
return EAI_MEMORY;
|
||||||
else
|
if (rc == IDNA_DLOPEN_ERROR)
|
||||||
{
|
return EAI_SYSTEM;
|
||||||
strncpy (host, h->h_name, hostlen);
|
return EAI_IDN_ENCODE;
|
||||||
ok = 1;
|
}
|
||||||
|
|
||||||
|
if (out != h->h_name)
|
||||||
|
{
|
||||||
|
h->h_name = strdupa (out);
|
||||||
|
free (out);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
size_t len = strlen (h->h_name) + 1;
|
||||||
|
if (len > hostlen)
|
||||||
|
return EAI_OVERFLOW;
|
||||||
|
|
||||||
|
memcpy (host, h->h_name, len);
|
||||||
|
|
||||||
|
ok = 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -390,8 +421,12 @@ getnameinfo (const struct sockaddr *sa, socklen_t addrlen, char *host,
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
__snprintf (serv, servlen, "%d",
|
|
||||||
ntohs (((const struct sockaddr_in *) sa)->sin_port));
|
if (__snprintf (serv, servlen, "%d",
|
||||||
|
ntohs (((const struct sockaddr_in *) sa)->sin_port))
|
||||||
|
+ 1 > servlen)
|
||||||
|
return EAI_OVERFLOW;
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case AF_LOCAL:
|
case AF_LOCAL:
|
||||||
|
Loading…
Reference in New Issue
Block a user