Backed out changeset ce887b471785 (bug 961313) for buffered_stun_socket_unittest crashes, again.

This commit is contained in:
Ryan VanderMeulen 2014-01-27 09:41:48 -05:00
parent ed4a205d50
commit 69cbc0bbff
2 changed files with 4 additions and 16 deletions

View File

@ -57,29 +57,17 @@ int nr_transport_addr_fmt_addr_string(nr_transport_addr *addr)
int _status;
/* Max length for normalized IPv6 address string represntation is 39 */
char buffer[40];
const char *protocol;
switch(addr->protocol){
case IPPROTO_TCP:
protocol = "TCP";
break;
case IPPROTO_UDP:
protocol = "UDP";
break;
default:
ABORT(R_INTERNAL);
}
switch(addr->ip_version){
case NR_IPV4:
if (!inet_ntop(AF_INET, &addr->u.addr4.sin_addr,buffer,sizeof(buffer)))
strcpy(buffer, "[error]");
snprintf(addr->as_string,sizeof(addr->as_string),"IP4:%s:%d/%s",buffer,ntohs(addr->u.addr4.sin_port),protocol);
snprintf(addr->as_string,sizeof(addr->as_string),"IP4:%s:%d",buffer,ntohs(addr->u.addr4.sin_port));
break;
case NR_IPV6:
if (!inet_ntop(AF_INET6, &addr->u.addr6.sin6_addr,buffer,sizeof(buffer)))
strcpy(buffer, "[error]");
snprintf(addr->as_string,sizeof(addr->as_string),"IP6:[%s]:%d/%s",buffer,ntohs(addr->u.addr6.sin6_port),protocol);
snprintf(addr->as_string,sizeof(addr->as_string),"IP6:[%s]:%d",buffer,ntohs(addr->u.addr6.sin6_port));
break;
default:
ABORT(R_INTERNAL);

View File

@ -67,8 +67,8 @@ typedef struct nr_transport_addr_ {
} u;
char ifname[MAXIFNAME];
/* A string version.
56 = 5 ("IP6:[") + 39 (ipv6 address) + 2 ("]:") + 5 (port) + 4 (/UDP) + 1 (null) */
char as_string[56];
52 = 5 ("IP6:[") + 39 (ipv6 address) + 2 ("]:") + 5 (port) + 1 (null) */
char as_string[52];
} nr_transport_addr;
int nr_sockaddr_to_transport_addr(struct sockaddr *saddr, int saddr_len, int protocol, int keep, nr_transport_addr *addr);