summaryrefslogtreecommitdiff
path: root/src/udp.c
diff options
context:
space:
mode:
authorChristian Pointner <equinox@anytun.org>2012-09-25 11:45:31 +0000
committerChristian Pointner <equinox@anytun.org>2012-09-25 11:45:31 +0000
commit4dda2b162fdab27197f371bb85842da581aee834 (patch)
treef0b10a52e541160c1739444923066c83e1c491ff /src/udp.c
parentconfigure script cleanup (diff)
-Wall cleanup
Diffstat (limited to 'src/udp.c')
-rw-r--r--src/udp.c9
1 files changed, 6 insertions, 3 deletions
diff --git a/src/udp.c b/src/udp.c
index e6865bd..1491d75 100644
--- a/src/udp.c
+++ b/src/udp.c
@@ -33,6 +33,9 @@
* along with uAnytun. If not, see <http://www.gnu.org/licenses/>.
*/
+#define _GNU_SOURCE
+#include <stdio.h>
+
#include "datatypes.h"
#include "udp.h"
@@ -240,7 +243,6 @@ void udp_close(udp_t* sock)
char* udp_endpoint_to_string(udp_endpoint_t e)
{
- size_t addrstr_len = 0;
char addrstr[INET6_ADDRSTRLEN + 1], portstr[6], *ret;
char addrport_sep = ':';
@@ -249,12 +251,13 @@ char* udp_endpoint_to_string(udp_endpoint_t e)
case AF_INET: addrport_sep = ':'; break;
case AF_INET6: addrport_sep = '.'; break;
case AF_UNSPEC: return NULL;
- default: asprintf(&ret, "unknown address type"); return ret;
+ default: return strdup("unknown address type");
}
int errcode = getnameinfo((struct sockaddr *)&(e.addr_), e.len_, addrstr, sizeof(addrstr), portstr, sizeof(portstr), NI_NUMERICHOST | NI_NUMERICSERV);
if (errcode != 0) return NULL;
- asprintf(&ret, "%s%c%s", addrstr, addrport_sep ,portstr);
+ int len = asprintf(&ret, "%s%c%s", addrstr, addrport_sep ,portstr);
+ if(len == -1) return NULL;
return ret;
}