Change in osmo-ggsn[master]: ggsn: Remove magic numbers from ipcp_contains_option()

2019-04-25 Thread Harald Welte
Harald Welte has posted comments on this change. ( 
https://gerrit.osmocom.org/13569 )

Change subject: ggsn: Remove magic numbers from ipcp_contains_option()
..


Patch Set 2: Code-Review+2


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

Gerrit-Project: osmo-ggsn
Gerrit-Branch: master
Gerrit-MessageType: comment
Gerrit-Change-Id: I5b1abc6f403f85986407e9e8359924dfcb58031a
Gerrit-Change-Number: 13569
Gerrit-PatchSet: 2
Gerrit-Owner: Harald Welte 
Gerrit-Reviewer: Harald Welte 
Gerrit-Reviewer: Jenkins Builder (102)
Gerrit-Reviewer: Pau Espin Pedrol 
Gerrit-Comment-Date: Thu, 25 Apr 2019 20:16:48 +
Gerrit-HasComments: No
Gerrit-HasLabels: Yes


Change in osmo-ggsn[master]: ggsn: Remove magic numbers from ipcp_contains_option()

2019-04-11 Thread Pau Espin Pedrol
Pau Espin Pedrol has posted comments on this change. ( 
https://gerrit.osmocom.org/13569 )

Change subject: ggsn: Remove magic numbers from ipcp_contains_option()
..


Patch Set 1:

(1 comment)

https://gerrit.osmocom.org/#/c/13569/1/ggsn/ggsn.c
File ggsn/ggsn.c:

https://gerrit.osmocom.org/#/c/13569/1/ggsn/ggsn.c@419
PS1, Line 419:  const uint8_t *cur_opt = ipcp + sizeof(struct ipcp_hdr);
Same as with previous commit: we can drop cur_opt completely.



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

Gerrit-Project: osmo-ggsn
Gerrit-Branch: master
Gerrit-MessageType: comment
Gerrit-Change-Id: I5b1abc6f403f85986407e9e8359924dfcb58031a
Gerrit-Change-Number: 13569
Gerrit-PatchSet: 1
Gerrit-Owner: Harald Welte 
Gerrit-Reviewer: Jenkins Builder (102)
Gerrit-Reviewer: Pau Espin Pedrol 
Gerrit-Comment-Date: Thu, 11 Apr 2019 14:21:49 +
Gerrit-HasComments: Yes
Gerrit-HasLabels: No


Change in osmo-ggsn[master]: ggsn: Remove magic numbers from ipcp_contains_option()

2019-04-10 Thread Harald Welte
Harald Welte has uploaded this change for review. ( 
https://gerrit.osmocom.org/13569


Change subject: ggsn: Remove magic numbers from ipcp_contains_option()
..

ggsn: Remove magic numbers from ipcp_contains_option()

Let's remove some magic numbers and use a data structure instead.

Change-Id: I5b1abc6f403f85986407e9e8359924dfcb58031a
---
M ggsn/ggsn.c
1 file changed, 7 insertions(+), 6 deletions(-)



  git pull ssh://gerrit.osmocom.org:29418/osmo-ggsn refs/changes/69/13569/1

diff --git a/ggsn/ggsn.c b/ggsn/ggsn.c
index 2c0d64e..2d1368b 100644
--- a/ggsn/ggsn.c
+++ b/ggsn/ggsn.c
@@ -419,14 +419,15 @@
const uint8_t *cur_opt = ipcp + sizeof(struct ipcp_hdr);

/* iterate over Options and check if protocol contained */
-   while (cur_opt + 2 <= ipcp + ipcp_len) {
-   uint8_t type = cur_opt[0];
-   uint8_t len = cur_opt[1]; /* length value includes 2 bytes 
type/length */
-   if (len < 2)
+   while (cur_opt + sizeof(struct ipcp_option_hdr) <= ipcp + ipcp_len) {
+   const struct ipcp_option_hdr *cur_opt_hdr = (const struct 
ipcp_option_hdr *)cur_opt;
+   /* length value includes 2 bytes type/length */
+   if (cur_opt_hdr->len < sizeof(struct ipcp_option_hdr))
return NULL;
-   if (type == opt && len >= 2 + opt_minlen)
+   if (cur_opt_hdr->type == opt &&
+   cur_opt_hdr->len >= sizeof(struct ipcp_option_hdr) + 
opt_minlen)
return cur_opt;
-   cur_opt += len;
+   cur_opt += cur_opt_hdr->len;
}
return NULL;
 }

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

Gerrit-Project: osmo-ggsn
Gerrit-Branch: master
Gerrit-MessageType: newchange
Gerrit-Change-Id: I5b1abc6f403f85986407e9e8359924dfcb58031a
Gerrit-Change-Number: 13569
Gerrit-PatchSet: 1
Gerrit-Owner: Harald Welte