diff options
author | Harald Welte <laforge@gnumonks.org> | 2017-08-12 14:54:28 +0200 |
---|---|---|
committer | Harald Welte <laforge@gnumonks.org> | 2017-09-05 22:42:17 +0200 |
commit | 33520b43ec662e9544e64f794261976bd517fa23 (patch) | |
tree | 26331421a06535135e3615fa37ccc20c2d4e915b /lib | |
parent | 7fc8694b976da8afdeeecc4779bcce08f354ee7d (diff) |
lib/in46_addr: Avoid ASSERT() when in46a_ntop() is called on uninitialized address
Change-Id: I42d41ec1370b9cc15d372b649d8e1bc78e76af9b
Diffstat (limited to 'lib')
-rw-r--r-- | lib/in46_addr.c | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/lib/in46_addr.c b/lib/in46_addr.c index 6864c64..4b5fd64 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; |