Change in libosmocore[master]: gprs_ns2_sns: add check for duplicates to add_ip6_elem()

laforge gerrit-no-reply at lists.osmocom.org
Sun Jun 13 18:31:25 UTC 2021


laforge has submitted this change. ( https://gerrit.osmocom.org/c/libosmocore/+/24586 )

Change subject: gprs_ns2_sns: add check for duplicates to add_ip6_elem()
......................................................................

gprs_ns2_sns: add check for duplicates to add_ip6_elem()

The ip4 version already checks for duplicates.

Related: OS#5036
Change-Id: I4a1528ea3427946ce465085919b2b522d3cedd07
---
M src/gb/gprs_ns2_sns.c
1 file changed, 8 insertions(+), 3 deletions(-)

Approvals:
  laforge: Looks good to me, approved
  Jenkins Builder: Verified



diff --git a/src/gb/gprs_ns2_sns.c b/src/gb/gprs_ns2_sns.c
index c50b2b9..1204266 100644
--- a/src/gb/gprs_ns2_sns.c
+++ b/src/gb/gprs_ns2_sns.c
@@ -452,10 +452,8 @@
 static int add_ip4_elem(struct ns2_sns_state *gss, struct ns2_sns_elems *elems,
 			const struct gprs_ns_ie_ip4_elem *ip4)
 {
-	unsigned int i;
-
 	/* check for duplicates */
-	for (i = 0; i < elems->num_ip4; i++) {
+	for (unsigned int i = 0; i < elems->num_ip4; i++) {
 		if (memcmp(&elems->ip4[i], ip4, sizeof(*ip4)))
 			continue;
 		return -1;
@@ -507,6 +505,13 @@
 static int add_ip6_elem(struct ns2_sns_state *gss, struct ns2_sns_elems *elems,
 			const struct gprs_ns_ie_ip6_elem *ip6)
 {
+	/* check for duplicates */
+	for (unsigned int i = 0; i < elems->num_ip6; i++) {
+		if (memcmp(&elems->ip6[i].ip_addr, &ip6->ip_addr, sizeof(ip6->ip_addr)) ||
+		    elems->ip6[i].udp_port != ip6->udp_port)
+			continue;
+		return -1;
+	}
 
 	elems->ip6 = talloc_realloc(gss, elems->ip6, struct gprs_ns_ie_ip6_elem,
 					 elems->num_ip6+1);

-- 
To view, visit https://gerrit.osmocom.org/c/libosmocore/+/24586
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings

Gerrit-Project: libosmocore
Gerrit-Branch: master
Gerrit-Change-Id: I4a1528ea3427946ce465085919b2b522d3cedd07
Gerrit-Change-Number: 24586
Gerrit-PatchSet: 3
Gerrit-Owner: lynxis lazus <lynxis at fe80.eu>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: dexter <pmaier at sysmocom.de>
Gerrit-Reviewer: laforge <laforge at osmocom.org>
Gerrit-Reviewer: pespin <pespin at sysmocom.de>
Gerrit-MessageType: merged
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osmocom.org/pipermail/gerrit-log/attachments/20210613/8fae92e8/attachment.htm>


More information about the gerrit-log mailing list