aboutsummaryrefslogtreecommitdiffstats
path: root/openbsc/src
diff options
context:
space:
mode:
authorNeels Hofmeyr <nhofmeyr@sysmocom.de>2017-05-12 15:37:27 +0200
committerNeels Hofmeyr <nhofmeyr@sysmocom.de>2017-05-12 15:43:49 +0200
commit7590ff3fd6cde4264f6e7961f8d9dcafbb526271 (patch)
tree23fe9722b6afc143d166444a38c4259aa3accb06 /openbsc/src
parent34ce3d93c52a734a7380114254a14ce8bcc77bb1 (diff)
fix subscriber random extension allocation range
The VTY config allows above 32bit range extensions, but db_subscriber_alloc_exten() was unable to generate extensions outside of 32bit. Add VTY regression test and fix the problem by using proper 64bit types. Related: OS#2253 Change-Id: I9afe6a8833004ecd2f3f936b2d5aa4de8e7dbcb0
Diffstat (limited to 'openbsc/src')
-rw-r--r--openbsc/src/libmsc/db.c8
1 files changed, 4 insertions, 4 deletions
diff --git a/openbsc/src/libmsc/db.c b/openbsc/src/libmsc/db.c
index 9fa64152..5fe2a3c6 100644
--- a/openbsc/src/libmsc/db.c
+++ b/openbsc/src/libmsc/db.c
@@ -1260,13 +1260,13 @@ int db_subscriber_alloc_exten(struct gsm_subscriber *subscriber, uint64_t smin,
uint64_t smax)
{
dbi_result result = NULL;
- uint32_t try;
+ uint64_t try;
for (;;) {
try = (rand() % (smax - smin + 1) + smin);
result = dbi_conn_queryf(conn,
"SELECT * FROM Subscriber "
- "WHERE extension = %i",
+ "WHERE extension = %"PRIu64,
try
);
if (!result) {
@@ -1284,8 +1284,8 @@ int db_subscriber_alloc_exten(struct gsm_subscriber *subscriber, uint64_t smin,
}
dbi_result_free(result);
}
- sprintf(subscriber->extension, "%i", try);
- DEBUGP(DDB, "Allocated extension %i for IMSI %s.\n", try, subscriber->imsi);
+ sprintf(subscriber->extension, "%"PRIu64, try);
+ DEBUGP(DDB, "Allocated extension %"PRIu64 " for IMSI %s.\n", try, subscriber->imsi);
return db_sync_subscriber(subscriber);
}
/*