<p>Vadim Yanitskiy has uploaded this change for <strong>review</strong>.</p><p><a href="https://gerrit.osmocom.org/14195">View Change</a></p><pre style="font-family: monospace,monospace; white-space: pre-wrap;">osmo-sgsn: get rid of OSMO_ASSERT() in 'auth-policy' handler<br><br>For some reason, libosmovty does accept incomplete commands<br>if a command definition contains 'choice' statements.<br><br>For example, the following command definition:<br><br>  auth-policy (accept-all|closed|acl-only|remote)<br><br>actually permits the following variations:<br><br>  auth-policy accept-all<br>  auth-policy accept<br>  auth-policy acl<br>  auth-policy re<br>  auth-policy c<br><br>so in case of such incomplete input, get_string_value() would fail<br>to find the corresponding enum value, and the whole process would<br>crash. That's not what a regular fun of the TAB-completion would<br>expect, right?<br><br>Instead of assert()ing the result of get_string_value(), let's<br>rather print a warning and return CMD_ERR_INCOMPLETE.<br><br>Change-Id: If9b0c0d031477ca87786aab5c269d00748e896c8<br>---<br>M src/gprs/sgsn_vty.c<br>1 file changed, 7 insertions(+), 3 deletions(-)<br><br></pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;">git pull ssh://gerrit.osmocom.org:29418/osmo-sgsn refs/changes/95/14195/1</pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;"><span>diff --git a/src/gprs/sgsn_vty.c b/src/gprs/sgsn_vty.c</span><br><span>index 9155441..969156f 100644</span><br><span>--- a/src/gprs/sgsn_vty.c</span><br><span>+++ b/src/gprs/sgsn_vty.c</span><br><span>@@ -725,9 +725,13 @@</span><br><span>      "Accept only subscribers in the ACL\n"</span><br><span>     "Use remote subscription data only (HLR)\n")</span><br><span> {</span><br><span style="color: hsl(0, 100%, 40%);">-     int val = get_string_value(sgsn_auth_pol_strs, argv[0]);</span><br><span style="color: hsl(0, 100%, 40%);">-        OSMO_ASSERT(val >= SGSN_AUTH_POLICY_OPEN && val <= SGSN_AUTH_POLICY_REMOTE);</span><br><span style="color: hsl(0, 100%, 40%);">-      g_cfg->auth_policy = val;</span><br><span style="color: hsl(120, 100%, 40%);">+  int val;</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+    val = get_string_value(sgsn_auth_pol_strs, argv[0]);</span><br><span style="color: hsl(120, 100%, 40%);">+  if (val < 0)</span><br><span style="color: hsl(120, 100%, 40%);">+               return CMD_ERR_INCOMPLETE;</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+  g_cfg->auth_policy = (enum sgsn_auth_policy) val;</span><br><span>         g_cfg->require_update_location = (val == SGSN_AUTH_POLICY_REMOTE);</span><br><span> </span><br><span>    /* Authentication is not possible without HLR */</span><br><span></span><br></pre><p>To view, visit <a href="https://gerrit.osmocom.org/14195">change 14195</a>. To unsubscribe, or for help writing mail filters, visit <a href="https://gerrit.osmocom.org/settings">settings</a>.</p><div itemscope itemtype="http://schema.org/EmailMessage"><div itemscope itemprop="action" itemtype="http://schema.org/ViewAction"><link itemprop="url" href="https://gerrit.osmocom.org/14195"/><meta itemprop="name" content="View Change"/></div></div>

<div style="display:none"> Gerrit-Project: osmo-sgsn </div>
<div style="display:none"> Gerrit-Branch: master </div>
<div style="display:none"> Gerrit-MessageType: newchange </div>
<div style="display:none"> Gerrit-Change-Id: If9b0c0d031477ca87786aab5c269d00748e896c8 </div>
<div style="display:none"> Gerrit-Change-Number: 14195 </div>
<div style="display:none"> Gerrit-PatchSet: 1 </div>
<div style="display:none"> Gerrit-Owner: Vadim Yanitskiy <axilirator@gmail.com> </div>