lynxis lazus has uploaded this change for review. ( 
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, 7 insertions(+), 3 deletions(-)



  git pull ssh://gerrit.osmocom.org:29418/libosmocore refs/changes/86/24586/1

diff --git a/src/gb/gprs_ns2_sns.c b/src/gb/gprs_ns2_sns.c
index c50b2b9..2e84d16 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,12 @@
 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], ip6, sizeof(*ip6)))
+                       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: 1
Gerrit-Owner: lynxis lazus <lyn...@fe80.eu>
Gerrit-MessageType: newchange

Reply via email to