Review at  https://gerrit.osmocom.org/3840

lib/in46_addr: Avoid ASSERT() when in46a_ntop() is called on uninitialized 
address

Change-Id: I42d41ec1370b9cc15d372b649d8e1bc78e76af9b
---
M lib/in46_addr.c
1 file changed, 8 insertions(+), 1 deletion(-)


  git pull ssh://gerrit.osmocom.org:29418/openggsn refs/changes/40/3840/1

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 @@
 /*! 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;
 

-- 
To view, visit https://gerrit.osmocom.org/3840
To unsubscribe, visit https://gerrit.osmocom.org/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I42d41ec1370b9cc15d372b649d8e1bc78e76af9b
Gerrit-PatchSet: 1
Gerrit-Project: openggsn
Gerrit-Branch: master
Gerrit-Owner: Harald Welte <[email protected]>

Reply via email to