From patchwork Thu Oct 8 14:10:24 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Willmann X-Patchwork-Id: 527728 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.osmocom.org (unknown [IPv6:2a01:4f8:191:444b::2:7]) by ozlabs.org (Postfix) with ESMTP id 6AED4140D95 for ; Fri, 9 Oct 2015 01:16:13 +1100 (AEDT) Received: from lists.osmocom.org (lists.osmocom.org [144.76.43.76]) by lists.osmocom.org (Postfix) with ESMTP id 14627952A; Thu, 8 Oct 2015 14:16:07 +0000 (UTC) X-Original-To: openbsc@lists.osmocom.org Delivered-To: openbsc@lists.osmocom.org Received: from isonoe.totalueberwachung.de (unknown [IPv6:2a01:198:210:100::1]) by lists.osmocom.org (Postfix) with ESMTP id 1317E94B2 for ; Thu, 8 Oct 2015 14:16:00 +0000 (UTC) Received: from adrastea.totalueberwachung.de (ip5b4185b8.dynamic.kabel-deutschland.de [91.65.133.184]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by isonoe.totalueberwachung.de (Postfix) with ESMTPSA id 5070B6007B; Thu, 8 Oct 2015 16:10:26 +0200 (CEST) Received: by adrastea.totalueberwachung.de (Postfix, from userid 1000) id 714F25014; Thu, 8 Oct 2015 16:10:27 +0200 (CEST) From: Daniel Willmann To: OpenBSC Mailing List Subject: [openbsc 2/4] gprs: Use RAND_bytes for p-tmsi Date: Thu, 8 Oct 2015 16:10:24 +0200 Message-Id: X-Mailer: git-send-email 2.1.4 In-Reply-To: References: In-Reply-To: References: X-BeenThere: openbsc@lists.osmocom.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: Development of the OpenBSC GSM base station controller List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Daniel Willmann Errors-To: openbsc-bounces@lists.osmocom.org Sender: "OpenBSC" From: Daniel Willmann --- 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