[MERGED] openbsc[master]: fix VTY parsing: subscriber-create-on-demand random

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/.

Neels Hofmeyr gerrit-no-reply at lists.osmocom.org
Sat May 13 22:09:46 UTC 2017


Neels Hofmeyr has submitted this change and it was merged.

Change subject: fix VTY parsing: subscriber-create-on-demand random
......................................................................


fix VTY parsing: subscriber-create-on-demand random

Fix parsing of the 'subscriber-create-on-demand random' VTY: atoi() is not
enough to include the specified range of 1-9999999999.

Use atoll() instead to ensure a large enough number space also on 32bit
systems.

(Note: for me, atoll() truncates at 32 bit when <stdlib.h> is not included.)

Add a VTY regression test for this.

Related: OS#2253
Change-Id: I353e04481ec567adca383d6b51ba8fb865eed73e
---
M openbsc/src/libmsc/vty_interface_layer3.c
M openbsc/tests/vty_test_runner.py
2 files changed, 12 insertions(+), 1 deletion(-)

Approvals:
  Harald Welte: Looks good to me, approved
  Jenkins Builder: Verified



diff --git a/openbsc/src/libmsc/vty_interface_layer3.c b/openbsc/src/libmsc/vty_interface_layer3.c
index f631bcc..e503291 100644
--- a/openbsc/src/libmsc/vty_interface_layer3.c
+++ b/openbsc/src/libmsc/vty_interface_layer3.c
@@ -1079,7 +1079,7 @@
       "Minimum for subscriber extension\n""Maximum for subscriber extension\n")
 {
 	struct gsm_network *gsmnet = gsmnet_from_vty(vty);
-	uint64_t mi = atoi(argv[0]), ma = atoi(argv[1]);
+	uint64_t mi = atoll(argv[0]), ma = atoll(argv[1]);
 	gsmnet->auto_create_subscr = true;
 	gsmnet->auto_assign_exten = true;
 	if (mi >= ma) {
diff --git a/openbsc/tests/vty_test_runner.py b/openbsc/tests/vty_test_runner.py
index 305c956..b886911 100644
--- a/openbsc/tests/vty_test_runner.py
+++ b/openbsc/tests/vty_test_runner.py
@@ -476,6 +476,17 @@
         res = self.vty.command('show subscriber imsi '+imsi)
         self.assert_(('% No subscriber found for imsi ' + imsi) == res)
 
+        # range
+        self.vty.command("end")
+        self.vty.command("configure terminal")
+        self.vty.command("nitb")
+        self.assertTrue(self.vty.verify("subscriber-create-on-demand random 9999999998 9999999999", ['']))
+        res = self.vty.command("show running-config")
+        self.assert_(res.find("subscriber-create-on-demand random 9999999998 9999999999"))
+        self.vty.command("end")
+
+
+
     def testSubscriberSettings(self):
         self.vty.enable()
 

-- 
To view, visit https://gerrit.osmocom.org/2583
To unsubscribe, visit https://gerrit.osmocom.org/settings

Gerrit-MessageType: merged
Gerrit-Change-Id: I353e04481ec567adca383d6b51ba8fb865eed73e
Gerrit-PatchSet: 1
Gerrit-Project: openbsc
Gerrit-Branch: master
Gerrit-Owner: Neels Hofmeyr <nhofmeyr at sysmocom.de>
Gerrit-Reviewer: Harald Welte <laforge at gnumonks.org>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: Neels Hofmeyr <nhofmeyr at sysmocom.de>



More information about the gerrit-log mailing list