Change in osmo-sgsn[master]: osmo-sgsn: get rid of OSMO_ASSERT() in 'auth-policy' handler

Vadim Yanitskiy gerrit-no-reply at lists.osmocom.org
Mon May 27 00:43:18 UTC 2019


Vadim Yanitskiy has uploaded this change for review. ( https://gerrit.osmocom.org/14195


Change subject: osmo-sgsn: get rid of OSMO_ASSERT() in 'auth-policy' handler
......................................................................

osmo-sgsn: get rid of OSMO_ASSERT() in 'auth-policy' handler

For some reason, libosmovty does accept incomplete commands
if a command definition contains 'choice' statements.

For example, the following command definition:

  auth-policy (accept-all|closed|acl-only|remote)

actually permits the following variations:

  auth-policy accept-all
  auth-policy accept
  auth-policy acl
  auth-policy re
  auth-policy c

so in case of such incomplete input, get_string_value() would fail
to find the corresponding enum value, and the whole process would
crash. That's not what a regular fun of the TAB-completion would
expect, right?

Instead of assert()ing the result of get_string_value(), let's
rather print a warning and return CMD_ERR_INCOMPLETE.

Change-Id: If9b0c0d031477ca87786aab5c269d00748e896c8
---
M src/gprs/sgsn_vty.c
1 file changed, 7 insertions(+), 3 deletions(-)



  git pull ssh://gerrit.osmocom.org:29418/osmo-sgsn refs/changes/95/14195/1

diff --git a/src/gprs/sgsn_vty.c b/src/gprs/sgsn_vty.c
index 9155441..969156f 100644
--- a/src/gprs/sgsn_vty.c
+++ b/src/gprs/sgsn_vty.c
@@ -725,9 +725,13 @@
 	"Accept only subscribers in the ACL\n"
 	"Use remote subscription data only (HLR)\n")
 {
-	int val = get_string_value(sgsn_auth_pol_strs, argv[0]);
-	OSMO_ASSERT(val >= SGSN_AUTH_POLICY_OPEN && val <= SGSN_AUTH_POLICY_REMOTE);
-	g_cfg->auth_policy = val;
+	int val;
+
+	val = get_string_value(sgsn_auth_pol_strs, argv[0]);
+	if (val < 0)
+		return CMD_ERR_INCOMPLETE;
+
+	g_cfg->auth_policy = (enum sgsn_auth_policy) val;
 	g_cfg->require_update_location = (val == SGSN_AUTH_POLICY_REMOTE);
 
 	/* Authentication is not possible without HLR */

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

Gerrit-Project: osmo-sgsn
Gerrit-Branch: master
Gerrit-MessageType: newchange
Gerrit-Change-Id: If9b0c0d031477ca87786aab5c269d00748e896c8
Gerrit-Change-Number: 14195
Gerrit-PatchSet: 1
Gerrit-Owner: Vadim Yanitskiy <axilirator at gmail.com>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osmocom.org/pipermail/gerrit-log/attachments/20190527/2903008e/attachment.html>


More information about the gerrit-log mailing list