View | Details | Raw Unified | Return to bug 20018
Collapse All | Expand All

(-)a/resolv/Versions (+1 lines)
Lines 27-32 libc { Link Here
27
    __h_errno; __resp;
27
    __h_errno; __resp;
28
28
29
    __res_iclose;
29
    __res_iclose;
30
    __inet_aton_cstr;
30
    __inet_pton_length;
31
    __inet_pton_length;
31
    __resolv_context_get;
32
    __resolv_context_get;
32
    __resolv_context_get_preinit;
33
    __resolv_context_get_preinit;
(-)a/resolv/inet_addr.c (-10 / +30 lines)
Lines 69-74 Link Here
69
69
70
#include <netinet/in.h>
70
#include <netinet/in.h>
71
#include <arpa/inet.h>
71
#include <arpa/inet.h>
72
#include <resolv/resolv-internal.h>
72
73
73
#include <ctype.h>
74
#include <ctype.h>
74
75
Lines 92-106 __inet_addr(const char *cp) { Link Here
92
}
93
}
93
weak_alias (__inet_addr, inet_addr)
94
weak_alias (__inet_addr, inet_addr)
94
95
95
/*
96
static int
96
 * Check whether "cp" is a valid ascii representation
97
inet_aton_internal(const char *cp, struct in_addr *addr,
97
 * of an Internet address and convert to a binary address.
98
	           int trailing_chars_allowed)
98
 * Returns 1 if the address is valid, 0 if not.
99
 * This replaces inet_addr, the return value from which
100
 * cannot distinguish between failure and a local broadcast address.
101
 */
102
int
103
__inet_aton(const char *cp, struct in_addr *addr)
104
{
99
{
105
	static const in_addr_t max[4] = { 0xffffffff, 0xffffff, 0xffff, 0xff };
100
	static const in_addr_t max[4] = { 0xffffffff, 0xffffff, 0xffff, 0xff };
106
	in_addr_t val;
101
	in_addr_t val;
Lines 155-161 __inet_aton(const char *cp, struct in_addr *addr) Link Here
155
	/*
150
	/*
156
	 * Check for trailing characters.
151
	 * Check for trailing characters.
157
	 */
152
	 */
158
	if (c != '\0' && (!isascii(c) || !isspace(c)))
153
	if (c != '\0' && (!trailing_chars_allowed
154
			|| !isascii(c) || !isspace(c)))
159
		goto ret_0;
155
		goto ret_0;
160
	/*
156
	/*
161
	 * Did we get a valid digit?
157
	 * Did we get a valid digit?
Lines 178-183 ret_0: Link Here
178
	__set_errno (saved_errno);
174
	__set_errno (saved_errno);
179
	return (0);
175
	return (0);
180
}
176
}
177
178
/*
179
 * Check whether "cp" is a valid ascii representation
180
 * of an Internet address and convert to a binary address.
181
 * Returns 1 if the address is valid, 0 if not.
182
 * This replaces inet_addr, the return value from which
183
 * cannot distinguish between failure and a local broadcast address.
184
 */
185
int
186
__inet_aton(const char *cp, struct in_addr *addr)
187
{
188
	return inet_aton_internal(cp, addr, 1);
189
}
190
191
/*
192
 * Similar to __inet_aton, but accepts only null-terminated strings.
193
 */
194
int
195
__inet_aton_cstr(const char *cp, struct in_addr *addr)
196
{
197
	return inet_aton_internal(cp, addr, 0);
198
}
199
181
weak_alias (__inet_aton, inet_aton)
200
weak_alias (__inet_aton, inet_aton)
182
libc_hidden_def (__inet_aton)
201
libc_hidden_def (__inet_aton)
183
libc_hidden_weak (inet_aton)
202
libc_hidden_weak (inet_aton)
203
libc_hidden_def (__inet_aton_cstr)
(-)a/resolv/resolv-internal.h (+5 lines)
Lines 97-100 int __res_nopt (struct resolv_context *, int n0, Link Here
97
int __inet_pton_length (int af, const char *src, size_t srclen, void *);
97
int __inet_pton_length (int af, const char *src, size_t srclen, void *);
98
libc_hidden_proto (__inet_pton_length)
98
libc_hidden_proto (__inet_pton_length)
99
99
100
/* Internal function similar to inet_aton.
101
   Accepts only null-terminated strings.  */
102
int __inet_aton_cstr(const char *cp, struct in_addr *addr);
103
libc_hidden_proto(__inet_aton_cstr)
104
100
#endif  /* _RESOLV_INTERNAL_H */
105
#endif  /* _RESOLV_INTERNAL_H */
(-)a/sysdeps/posix/getaddrinfo.c (-1 / +1 lines)
Lines 504-510 gaih_inet (const char *name, const struct gaih_service *service, Link Here
504
	}
504
	}
505
#endif
505
#endif
506
506
507
      if (__inet_aton (name, (struct in_addr *) at->addr) != 0)
507
      if (__inet_aton_cstr (name, (struct in_addr *) at->addr) != 0)
508
	{
508
	{
509
	  if (req->ai_family == AF_UNSPEC || req->ai_family == AF_INET)
509
	  if (req->ai_family == AF_UNSPEC || req->ai_family == AF_INET)
510
	    at->family = AF_INET;
510
	    at->family = AF_INET;

Return to bug 20018