mirror of
https://gitlab.torproject.org/tpo/core/tor.git
synced 2024-11-13 06:33:44 +01:00
r13848@catbus: nickm | 2007-07-19 16:47:16 -0400
Use our own version of inet_ntop and inet_pton everywhere, to avoid partitioning attacks. svn:r10888
This commit is contained in:
parent
3015129a4a
commit
6223160ab7
@ -819,9 +819,6 @@ tor_inet_aton(const char *c, struct in_addr* addr)
|
|||||||
const char *
|
const char *
|
||||||
tor_inet_ntop(int af, const void *src, char *dst, size_t len)
|
tor_inet_ntop(int af, const void *src, char *dst, size_t len)
|
||||||
{
|
{
|
||||||
#ifdef HAVE_INET_NTOP
|
|
||||||
return inet_ntop(af,src,dst,(socklen_t)len);
|
|
||||||
#else
|
|
||||||
if (af == AF_INET) {
|
if (af == AF_INET) {
|
||||||
if (tor_inet_ntoa(src, dst, len) < 0)
|
if (tor_inet_ntoa(src, dst, len) < 0)
|
||||||
return NULL;
|
return NULL;
|
||||||
@ -896,7 +893,6 @@ tor_inet_ntop(int af, const void *src, char *dst, size_t len)
|
|||||||
} else {
|
} else {
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Given <b>af</b>==AF_INET or <b>af</b>==AF_INET6, and a string <b>src</b>
|
/** Given <b>af</b>==AF_INET or <b>af</b>==AF_INET6, and a string <b>src</b>
|
||||||
@ -911,9 +907,6 @@ tor_inet_ntop(int af, const void *src, char *dst, size_t len)
|
|||||||
int
|
int
|
||||||
tor_inet_pton(int af, const char *src, void *dst)
|
tor_inet_pton(int af, const char *src, void *dst)
|
||||||
{
|
{
|
||||||
#ifdef HAVE_INET_PTON
|
|
||||||
return inet_pton(af, src, dst);
|
|
||||||
#else
|
|
||||||
if (af == AF_INET) {
|
if (af == AF_INET) {
|
||||||
return tor_inet_aton(src, dst);
|
return tor_inet_aton(src, dst);
|
||||||
} else if (af == AF_INET6) {
|
} else if (af == AF_INET6) {
|
||||||
@ -1000,7 +993,6 @@ tor_inet_pton(int af, const char *src, void *dst)
|
|||||||
} else {
|
} else {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Similar behavior to Unix gethostbyname: resolve <b>name</b>, and set
|
/** Similar behavior to Unix gethostbyname: resolve <b>name</b>, and set
|
||||||
|
@ -1243,13 +1243,10 @@ test_ip6_helpers(void)
|
|||||||
test_assert(r == -1);
|
test_assert(r == -1);
|
||||||
r=tor_addr_parse_mask_ports("efef::/112", &t1, NULL, NULL, NULL);
|
r=tor_addr_parse_mask_ports("efef::/112", &t1, NULL, NULL, NULL);
|
||||||
test_assert(r == -1);
|
test_assert(r == -1);
|
||||||
#if 0
|
|
||||||
/* These two are okay on OSX and some BSDs. */
|
|
||||||
r=tor_addr_parse_mask_ports("[f:f:f:f:f:f:f:f::]", &t1, NULL, NULL, NULL);
|
r=tor_addr_parse_mask_ports("[f:f:f:f:f:f:f:f::]", &t1, NULL, NULL, NULL);
|
||||||
test_assert(r == -1);
|
test_assert(r == -1);
|
||||||
r=tor_addr_parse_mask_ports("[::f:f:f:f:f:f:f:f]", &t1, NULL, NULL, NULL);
|
r=tor_addr_parse_mask_ports("[::f:f:f:f:f:f:f:f]", &t1, NULL, NULL, NULL);
|
||||||
test_assert(r == -1);
|
test_assert(r == -1);
|
||||||
#endif
|
|
||||||
r=tor_addr_parse_mask_ports("[f:f:f:f:f:f:f:f:f]", &t1, NULL, NULL, NULL);
|
r=tor_addr_parse_mask_ports("[f:f:f:f:f:f:f:f:f]", &t1, NULL, NULL, NULL);
|
||||||
test_assert(r == -1);
|
test_assert(r == -1);
|
||||||
/* Test for V4-mapped address with mask < 96. (arguably not valid) */
|
/* Test for V4-mapped address with mask < 96. (arguably not valid) */
|
||||||
|
Loading…
Reference in New Issue
Block a user