[PATCH] openggsn[master]: lib/in46_addr: Avoid ASSERT() when in46a_ntop() is called on...

This is merely a historical archive of years 2008-2021, before the migration to mailman3.

A maintained and still updated list archive can be found at https://lists.osmocom.org/hyperkitty/list/gerrit-log@lists.osmocom.org/.

Harald Welte gerrit-no-reply at lists.osmocom.org
Tue Sep 5 20:26:47 UTC 2017


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 <laforge at gnumonks.org>



More information about the gerrit-log mailing list