[openbsc 4/4] libmsc: Use RAND_bytes to generate a token

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:26 UTC 2015


From: Daniel Willmann <dwillmann at sysmocom.de>

---
 openbsc/src/libmsc/db.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/openbsc/src/libmsc/db.c b/openbsc/src/libmsc/db.c
index faae982..863a092 100644
--- a/openbsc/src/libmsc/db.c
+++ b/openbsc/src/libmsc/db.c
@@ -1275,7 +1275,10 @@ int db_subscriber_alloc_token(struct gsm_subscriber *subscriber, uint32_t *token
 	uint32_t try;
 
 	for (;;) {
-		try = rand();
+		if (RAND_bytes(&try, sizeof(try)) != 1) {
+			LOGP(DDB, LOGL_ERROR, "RAND_bytes failed\n");
+			return 1;
+		}
 		if (!try) /* 0 is an invalid token */
 			continue;
 		result = dbi_conn_queryf(conn,
-- 
2.1.4




More information about the OpenBSC mailing list