Osmocom Mobile Switching Centre
Go to file
Vadim Yanitskiy 96262a7ca6 libmsc/sms_queue.c: fix memleak in smsq_take_next_sms()
A memleak has been noticed after executing some of TTCN-3 test
cases. For example, the following ones:

  - MSC_Tests.TC_lu_and_mo_sms,
  - MSC_Tests.TC_lu_and_mt_sms.

The key point is that MSC_Tests.TC_lu_and_mo_sms basically sends
a MO SMS to a non-attached subscriber with MSISDN 12345, so this
message is getting stored in the SMSC's database.

As soon as the SMSC's queue is triggered, sms_submit_pending() would
retrieve pending messages from the database by calling function
smsq_take_next_sms() in loop and attempt to deliver them.

This function in it's turn checks whether the subscriber is attached
or not. If not, the allocated 'gsm_sms' structure would not be
free()ed! Therefore, every time smsq_take_next_sms() is called,
one 'gsm_sms' structure for an unattached subscriber is leaked.

Furthermore, there is a unit test called 'sms_queue_test', that
actually does cover smsq_take_next_sms() and was designed to
catch some potential memory leaks, but...

In order to avoid emulating the low-level SQLite API, the unit
test by design overwrites some functions of libmsc, including
db_sms_get_next_unsent_rr_msisdn(), that is being called by
smsq_take_next_sms().

The problem is that the original function in libmsc does
allocate a 'gsm_sms' structure on heap (using talloc), while
the overwriting function did this statically, returning a
pointer to stack. This critical difference made it impossible
to spot the memleak in smsq_take_next_sms() during the
unit test execution.

Let's refactor 'sms_queue_test' to use dynamic memory allocation,
and finally fix the evil memleak in smsq_take_next_sms().

Change-Id: Iad5e4d84d8d410ea43d5907e9ddf6e5fdb55bc7a
Closes: OS#3860
2019-04-01 12:02:57 +00:00
contrib contrib: fix makedistcheck with disabled systemd 2018-12-06 16:31:01 +00:00
debian debian/control: Fix typo 2019-03-27 11:42:29 +00:00
doc build manuals moved here from osmo-gsm-manuals.git 2018-11-27 17:50:54 +01:00
include libvlr: Allow 2G auth tuples to be re-used without going through AUTH 2019-03-19 15:24:01 +00:00
m4 move openbsc/* to repos root 2017-07-12 23:17:10 +00:00
src libmsc/sms_queue.c: fix memleak in smsq_take_next_sms() 2019-04-01 12:02:57 +00:00
tests libmsc/sms_queue.c: fix memleak in smsq_take_next_sms() 2019-04-01 12:02:57 +00:00
.gitignore build manuals moved here from osmo-gsm-manuals.git 2018-11-27 17:50:54 +01:00
.gitreview update .gitreview to new repo url 2017-08-08 17:26:28 +02:00
.mailmap add .mailmap file for mapping git author name/mail in shortlog 2016-08-08 17:40:28 +00:00
AUTHORS move openbsc/* to repos root 2017-07-12 23:17:10 +00:00
COPYING move openbsc/* to repos root 2017-07-12 23:17:10 +00:00
Makefile.am Fix DISTCHECK_CONFIGURE_FLAGS override 2018-12-04 15:37:37 +01:00
README rewrite README 2017-09-06 16:33:41 +02:00
README.vty-tests Remove obsolete ./configure option 2017-11-29 14:24:54 +00:00
configure.ac configure.ac: Check for libsctp 2019-02-06 18:08:59 +00:00
git-version-gen git-version-gen: Don't check for .git directory 2018-07-24 18:05:46 +02:00
osmoappdesc.py doc/examples: add detailed cs7 config examples 2017-09-07 03:10:36 +02:00

README

About OsmoMSC
=============

OsmoMSC originated from the OpenBSC project, which started as a minimalistic
all-in-one implementation of the GSM Network. In 2017, OpenBSC had reached
maturity and diversity (including M3UA SIGTRAN and 3G support in the form of
IuCS and IuPS interfaces) that naturally lead to a separation of the all-in-one
approach to fully independent separate programs as in typical GSM networks.

OsmoMSC was one of the parts split off from the old openbsc.git. Before, it was
the libmsc part of the old OsmoNITB. Since a true A interface and IuCS for 3G
support is available, OsmoMSC exists only as a separate standalone entity.

OsmoMSC exposes
- GSUP towards OsmoHLR (or a MAP proxy);
- A over IP towards a BSC (e.g. OsmoBSC);
- IuCS towards an RNC or HNB-GW (e.g. OsmoHNBGW) for 3G voice;
- MNCC (Mobile Network Call Control derived from GSM TS 04.07);
- SMPP 3.4 (Short Message Peer-to-Peer);
- The Osmocom typical telnet VTY and CTRL interfaces.

Find OsmoMSC issue tracker and wiki online at
https://osmocom.org/projects/osmomsc
https://osmocom.org/projects/osmomsc/wiki