[MERGED] 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 21:06:03 UTC 2017


Harald Welte has submitted this change and it was merged.

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


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(-)

Approvals:
  Harald Welte: Looks good to me, approved
  Jenkins Builder: Verified



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: merged
Gerrit-Change-Id: I42d41ec1370b9cc15d372b649d8e1bc78e76af9b
Gerrit-PatchSet: 3
Gerrit-Project: openggsn
Gerrit-Branch: master
Gerrit-Owner: Harald Welte <laforge at gnumonks.org>
Gerrit-Reviewer: Harald Welte <laforge at gnumonks.org>
Gerrit-Reviewer: Jenkins Builder



More information about the gerrit-log mailing list