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/.
laforge gerrit-no-reply at lists.osmocom.orglaforge has submitted this change. ( https://gerrit.osmocom.org/c/libosmo-sccp/+/16831 )
Change subject: ss7: Improve checks in osmo_ss7_asp_peer_add_host()
......................................................................
ss7: Improve checks in osmo_ss7_asp_peer_add_host()
* Introduce check to make sure we don't write out of peer->host bounds.
* Clean up any/specific address checks, it should be more clear now.
Change-Id: I3ecb94267acbec6ecf2134b08110f24f131cd8cf
---
M src/osmo_ss7.c
1 file changed, 17 insertions(+), 11 deletions(-)
Approvals:
Jenkins Builder: Verified
osmith: Looks good to me, but someone else must approve
laforge: Looks good to me, approved
diff --git a/src/osmo_ss7.c b/src/osmo_ss7.c
index 70ec847..b7d69cb 100644
--- a/src/osmo_ss7.c
+++ b/src/osmo_ss7.c
@@ -1149,19 +1149,25 @@
bool new_is_any = !host || !strcmp(host, "0.0.0.0");
bool iter_is_any;
- /* Makes no sense to have INET_ANY and specific addresses in the set */
- for (i = 0; i < peer->host_cnt; i++) {
- iter_is_any = !peer->host[i] ||
- !strcmp(peer->host[i], "0.0.0.0");
- if (new_is_any && iter_is_any)
- return -EINVAL;
- if (!new_is_any && iter_is_any)
- return -EINVAL;
- }
- /* Makes no sense to have INET_ANY many times */
- if (new_is_any && peer->host_cnt)
+ if (peer->host_cnt >= ARRAY_SIZE(peer->host))
return -EINVAL;
+ /* Makes no sense to have INET_ANY many times, or INET_ANY together with
+ specific addresses: */
+ if (new_is_any && peer->host_cnt != 0)
+ return -EINVAL;
+
+ /* Makes no sense to add specific address to set if INET_ANY is
+ already set: */
+ if (!new_is_any) {
+ for (i = 0; i < peer->host_cnt; i++) {
+ iter_is_any = !peer->host[i] ||
+ !strcmp(peer->host[i], "0.0.0.0");
+ if (iter_is_any)
+ return -EINVAL;
+ }
+ }
+
osmo_talloc_replace_string(talloc_ctx, &peer->host[peer->host_cnt], host);
peer->host_cnt++;
return 0;
--
To view, visit https://gerrit.osmocom.org/c/libosmo-sccp/+/16831
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings
Gerrit-Project: libosmo-sccp
Gerrit-Branch: master
Gerrit-Change-Id: I3ecb94267acbec6ecf2134b08110f24f131cd8cf
Gerrit-Change-Number: 16831
Gerrit-PatchSet: 1
Gerrit-Owner: pespin <pespin at sysmocom.de>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: laforge <laforge at osmocom.org>
Gerrit-Reviewer: osmith <osmith at sysmocom.de>
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/20200115/12c8a56e/attachment.htm>