aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHarald Welte <laforge@gnumonks.org>2017-08-12 14:54:28 +0200
committerHarald Welte <laforge@gnumonks.org>2017-08-12 15:11:45 +0200
commite4d6b50309e0e94fd7caa1d417e4f1aa7aa4b2cc (patch)
tree1e3eece96d9bf65b6fbd5ebb0d25e3d27a7cc63c
parent87ec4c27ff446505840737e0e64f7b72c24301c4 (diff)
lib/in46_addr: Avoid ASSERT() when in46a_ntop() is called on uninitialized address
-rw-r--r--lib/in46_addr.c9
1 files changed, 8 insertions, 1 deletions
diff --git a/lib/in46_addr.c b/lib/in46_addr.c
index 4e7cbcd..01bdc5c 100644
--- a/lib/in46_addr.c
+++ b/lib/in46_addr.c
@@ -62,7 +62,14 @@ int in46a_to_sas(struct sockaddr_storage *out, const struct in46_addr *in)
/*! Convenience wrapper around inet_ntop() for \ref in46_addr */
const char *in46a_ntop(const struct in46_addr *in, char *dst, socklen_t dst_size)
{
- int af = in46a_to_af(in);
+ int af;
+
+ if (!in || in->len == 0) {
+ strncpy(dst, "UNDEFINED", dst_size);
+ return dst;
+ }
+
+ af = in46a_to_af(in);
if (af < 0)
return NULL;