summaryrefslogtreecommitdiffstats
path: root/src/host/layer23/src/mobile/gsm48_mm.c
diff options
context:
space:
mode:
authorVadim Yanitskiy <axilirator@gmail.com>2018-07-16 22:05:38 +0000
committerVadim Yanitskiy <axilirator@gmail.com>2018-07-17 05:09:58 +0700
commita0eef8d2e89ddd610bd8d8aa7511d444bd6590ca (patch)
treed615c3ba2625950585014b9aaf0a0b53fe80b354 /src/host/layer23/src/mobile/gsm48_mm.c
parent70a50a33ccb1d2fcf52a46bcabf5ffd8534c883d (diff)
Revert "Move from libc random() to osmo_get_rand_id"
It was decided to migrate to osmo_get_rand_id() and use random() as a fall-back. But there is a critical difference between both functions: osmo_get_rand_id() fills an input buffer with random bytes (0x00 - 0xff), while *random() returns a value in range between 0 and RAND_MAX. osmo_get_rand_id() was used in a wrong way, so in some cases we could get a negative value (how about IMEI starting from '-'?), what isn't expected in many cases and could lead to unexpected behaviour and segmentation faults... This reverts commit 6d49b049ee304f1ea0e4801df61e69713b01f0f8. Change-Id: I7b2a8a5c63cf64360a824926a2219fd7e419b1bb
Diffstat (limited to 'src/host/layer23/src/mobile/gsm48_mm.c')
-rw-r--r--src/host/layer23/src/mobile/gsm48_mm.c5
1 files changed, 1 insertions, 4 deletions
diff --git a/src/host/layer23/src/mobile/gsm48_mm.c b/src/host/layer23/src/mobile/gsm48_mm.c
index a36e7e86..a7af1f5c 100644
--- a/src/host/layer23/src/mobile/gsm48_mm.c
+++ b/src/host/layer23/src/mobile/gsm48_mm.c
@@ -30,7 +30,6 @@
#include <osmocom/core/utils.h>
#include <osmocom/gsm/gsm48.h>
#include <osmocom/core/talloc.h>
-#include <osmocom/gsm/gsm_utils.h>
#include <osmocom/bb/common/logging.h>
#include <osmocom/bb/common/osmocom_data.h>
@@ -2100,9 +2099,7 @@ static int gsm48_mm_sysinfo(struct osmocom_ms *ms, struct msgb *msg)
mm->t3212.timeout.tv_sec = current_time.tv_sec
+ (t % s->t3212);
} else {
- uint32_t rand;
- if (osmo_get_rand_id((uint8_t *) &rand, sizeof(rand)) != 0)
- rand = random();
+ uint32_t rand = random();
LOGP(DMM, LOGL_INFO, "New T3212 while timer is not "
"running (value %d)\n", s->t3212);