aboutsummaryrefslogtreecommitdiff
path: root/src/util/common_logging.c
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2010-06-18 16:54:44 +0000
committerChristian Grothoff <christian@grothoff.org>2010-06-18 16:54:44 +0000
commit4082afb814ba90c804e410cf0d33336262183dd3 (patch)
tree904e2366035971ddb143ae53e77abe29cf87e478 /src/util/common_logging.c
parent3c907f37c372d0cf35f5cb5f5fc4961a2fd8ef44 (diff)
downloadgnunet-4082afb814ba90c804e410cf0d33336262183dd3.tar.gz
gnunet-4082afb814ba90c804e410cf0d33336262183dd3.zip
check len
Diffstat (limited to 'src/util/common_logging.c')
-rw-r--r--src/util/common_logging.c6
1 files changed, 6 insertions, 0 deletions
diff --git a/src/util/common_logging.c b/src/util/common_logging.c
index 003696a48..dd490dda3 100644
--- a/src/util/common_logging.c
+++ b/src/util/common_logging.c
@@ -524,6 +524,8 @@ GNUNET_a2s (const struct sockaddr *addr, socklen_t addrlen)
524 switch (addr->sa_family) 524 switch (addr->sa_family)
525 { 525 {
526 case AF_INET: 526 case AF_INET:
527 if (addrlen != sizeof (struct sockaddr_in))
528 return "<invalid v4 address>";
527 v4 = (const struct sockaddr_in *) addr; 529 v4 = (const struct sockaddr_in *) addr;
528 inet_ntop (AF_INET, &v4->sin_addr, buf, INET_ADDRSTRLEN); 530 inet_ntop (AF_INET, &v4->sin_addr, buf, INET_ADDRSTRLEN);
529 if (0 == ntohs (v4->sin_port)) 531 if (0 == ntohs (v4->sin_port))
@@ -533,6 +535,8 @@ GNUNET_a2s (const struct sockaddr *addr, socklen_t addrlen)
533 strcat (buf, b2); 535 strcat (buf, b2);
534 return buf; 536 return buf;
535 case AF_INET6: 537 case AF_INET6:
538 if (addrlen != sizeof (struct sockaddr_in6))
539 return "<invalid v4 address>";
536 v6 = (const struct sockaddr_in6 *) addr; 540 v6 = (const struct sockaddr_in6 *) addr;
537 buf[0] = '['; 541 buf[0] = '[';
538 inet_ntop (AF_INET6, &v6->sin6_addr, &buf[1], INET6_ADDRSTRLEN); 542 inet_ntop (AF_INET6, &v6->sin6_addr, &buf[1], INET6_ADDRSTRLEN);
@@ -543,6 +547,8 @@ GNUNET_a2s (const struct sockaddr *addr, socklen_t addrlen)
543 strcat (buf, b2); 547 strcat (buf, b2);
544 return buf; 548 return buf;
545 case AF_UNIX: 549 case AF_UNIX:
550 if (addrlen <= sizeof (sa_family_t))
551 return "<invalid UNIX address>";
546 un = (const struct sockaddr_un*) addr; 552 un = (const struct sockaddr_un*) addr;
547 off = 0; 553 off = 0;
548 if (un->sun_path[0] == '\0') off++; 554 if (un->sun_path[0] == '\0') off++;