[openbsc 2/4] gprs: Use RAND_bytes for p-tmsi

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/OpenBSC@lists.osmocom.org/.

Daniel Willmann dwilllmann at sysmocom.de
Thu Oct 8 14:10:24 UTC 2015


From: Daniel Willmann <dwillmann at sysmocom.de>

---
 openbsc/src/gprs/gprs_sgsn.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/openbsc/src/gprs/gprs_sgsn.c b/openbsc/src/gprs/gprs_sgsn.c
index f40de0b..2af1e97 100644
--- a/openbsc/src/gprs/gprs_sgsn.c
+++ b/openbsc/src/gprs/gprs_sgsn.c
@@ -525,7 +525,9 @@ uint32_t sgsn_alloc_ptmsi(void)
 	int max_retries = 100;
 
 restart:
-	ptmsi = rand();
+	if (RAND_bytes(&ptmsi, sizeof(ptmsi)) != 1)
+		goto failed;
+
 	/* Enforce that the 2 MSB are set without loosing the distance between
 	 * identical values. Since rand() has no duplicate values within a
 	 * period (because the size of the state is the same like the size of
-- 
2.1.4




More information about the OpenBSC mailing list