Change in osmo-ttcn3-hacks[master]: library/Osmocom_Types: fix maximum values passed to f_rnd_int()

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

fixeria gerrit-no-reply at lists.osmocom.org
Fri Dec 10 23:11:43 UTC 2021


fixeria has uploaded this change for review. ( https://gerrit.osmocom.org/c/osmo-ttcn3-hacks/+/26508 )


Change subject: library/Osmocom_Types: fix maximum values passed to f_rnd_int()
......................................................................

library/Osmocom_Types: fix maximum values passed to f_rnd_int()

It's clearly stated in a comment to this function that the returned
value is 0 <= x < max, so it's always less than the maximum.

Change-Id: If127fc6a2feeddbdd3ea636b56dadf8957941758
---
M library/Osmocom_Types.ttcn
1 file changed, 4 insertions(+), 4 deletions(-)



  git pull ssh://gerrit.osmocom.org:29418/osmo-ttcn3-hacks refs/changes/08/26508/1

diff --git a/library/Osmocom_Types.ttcn b/library/Osmocom_Types.ttcn
index 3c0137c..967beb4 100644
--- a/library/Osmocom_Types.ttcn
+++ b/library/Osmocom_Types.ttcn
@@ -65,7 +65,7 @@
 }
 
 /* return hexstring composed of random digits */
-function f_rnd_hexstring(in integer len, in integer max := 15) return hexstring {
+function f_rnd_hexstring(in integer len, in integer max := 16) return hexstring {
 	var integer i;
 	var hexstring ret := ''H;
 	for (i := 0; i < len; i := i + 1) {
@@ -79,7 +79,7 @@
 	var integer i;
 	var octetstring ret := ''O;
 	for (i := 0; i < len; i := i + 1) {
-		ret := ret & int2oct(f_rnd_int(255), 1);
+		ret := ret & int2oct(f_rnd_int(256), 1);
 	}
 	return ret;
 }
@@ -91,7 +91,7 @@
 }
 
 function f_rnd_imsi(in hexstring prefix) return hexstring {
-	return prefix & f_rnd_hexstring(15 - lengthof(prefix), 9);
+	return prefix & f_rnd_hexstring(15 - lengthof(prefix), 10);
 }
 
 function f_rnd_msisdn(in octetstring prefix, integer len := 6) return octetstring {
@@ -249,7 +249,7 @@
 
 /* generate a random 11-bit RA (packet-switched only) */
 function f_rnd_ra11_ps() return BIT11 {
-	var integer ra11 := f_rnd_int(bit2int('11111111111'B));
+	var integer ra11 := f_rnd_int(bit2int('11111111111'B) + 1);
 	return int2bit(ra11, 11);
 }
 

-- 
To view, visit https://gerrit.osmocom.org/c/osmo-ttcn3-hacks/+/26508
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings

Gerrit-Project: osmo-ttcn3-hacks
Gerrit-Branch: master
Gerrit-Change-Id: If127fc6a2feeddbdd3ea636b56dadf8957941758
Gerrit-Change-Number: 26508
Gerrit-PatchSet: 1
Gerrit-Owner: fixeria <vyanitskiy at sysmocom.de>
Gerrit-MessageType: newchange
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osmocom.org/pipermail/gerrit-log/attachments/20211210/3086da49/attachment.htm>


More information about the gerrit-log mailing list