Commit Graph

16 Commits

Author SHA1 Message Date
Harald Welte 022193da73 smpp: Fix use-after-free bug when ESME disconnects but has write pending
When the SMPP code free's an ESME it also free's the related write_queue
and the osmo_fd contained therein.  So if this happens while we are
in esme_link_read_cb(), we must return -EBADF to make
osmo_wqueue_bfd_cb() of libosmocore avoid further accessing related
memory.

Change-Id: I441d3b05c2f2556c530783a7f66c73adf6d845a1
Closes: OS#5565
2022-05-16 17:33:42 +02:00
Vadim Yanitskiy e0661105ac smpp_smsc: use osmo_talloc_replace_string() in smpp_smsc_conf()
Change-Id: Ie3dc0d9673a0410a5908cba77fc352d581bac6f6
Fixes: CID#240711
2021-10-30 02:27:21 +00:00
Harald Welte aa29e33cb5 Use osmo_fd_setup() whenever applicable
Change-Id: Ib570e2ada619b72001d76d2cae159d78f09d6fb6
2020-10-19 11:38:05 +00:00
Pau Espin c95c0b6dd6 Use OSMO_FD_* instead of deprecated BSC_FD_*
New define is available since libosmocore 1.1.0, and we already require
1.3.0, so no need to update dependenices.
Let's change it to avoid people re-using old BSC_FD_* symbols when
copy-pasting somewhere else.

Change-Id: Ifc89fffac0443d94f3e49555684975b293ef90fb
2020-05-09 19:18:40 +02:00
Keith Whyte b67131595f Use GSM411_RP_* and not GSM48_CC_*
d34ed5768c introduced
comparison of GSM411_RP_CAUSE_MO_NUM_UNASSIGNED with
GSM48_CC_CAUSE_UNASSIGNED_NR

For consistency lets use the GSM411_RP constants
in SMS related code.

Change-Id: Ie54966560f66d2dcde905feb2eb19ef90406acd1
2020-01-11 13:07:14 +01:00
Harald Welte 5dede769e7 smpp_smsc: Call destroy_tlv() when using build_tlv()
The libsmpp34 build_tlv() function is allocating dynamic memory
which we need to release again by calling destroy_tlv().

Change-Id: Iacc74c9948fb10fa79c0dd7b0cb72d4adbefdeed
Closes: OS#3912
2019-04-10 10:53:23 +00:00
Keith Whyte c6d219cd83 Make alert notifications vty configurable per ESME
Adds (no) alert-notifications as a per-esme vty command,
in order to allow some ESMEs to be excluded from alerts.

The default is still to send alert notifications to all esme,
so no changes are required to the config file to maintain
identical operation after this patch.

Change-Id: I57f4d268ca6fe6a233f2caaffce62e4aade01274
2019-01-17 14:03:27 +00:00
Pau Espin 7e300d8741 smpp_smsc_conf: Fix heap-use-after-free
Fixes following error catched by enabling address sanitizer:
==20792==ERROR: AddressSanitizer: heap-use-after-free on address 0x60b000122610 at pc 0x7f9c9c3fe063 bp 0x7ffd2e68f600 sp 0x7ffd2e68edb0
READ of size 11 at 0x60b000122610 thread T0
    #0 0x7f9c9c3fe062  (/usr/lib/x86_64-linux-gnu/libasan.so.3+0x3c062)
    #1 0x7f9c9beb8ee4 in talloc_strdup (/usr/lib/x86_64-linux-gnu/libtalloc.so.2+0x6ee4)
    #2 0x56096a7cf75b in smpp_smsc_conf src/libmsc/smpp_smsc.c:983
    #3 0x56096a7cf9df in smpp_smsc_start src/libmsc/smpp_smsc.c:1015
    #4 0x56096a7d4935 in smpp_openbsc_start src/libmsc/smpp_openbsc.c:785
    #5 0x56096a755ad0 in main src/osmo-msc/msc_main.c:598
    #6 0x7f9c9927b2e0 in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x202e0)
    #7 0x56096a756979 in _start (/home/jenkins/workspace/osmo-gsm-tester_run-prod/trial-805/inst/osmo-msc/bin/osmo-msc+0xf0979)

Related: OS#3181

Change-Id: Iaf0d251c8d2912266a087ada4d20905146e08592
2018-04-17 16:10:35 +02:00
Harald Welte ce96928e12 smpp: Unset esme->acl on socket close
We set acl->esme during _process_bind(), but we don't clear it
in case the TCP connection for the ESME is dead.  This leads to
a stale acl->esme pointer, which we will attempt to dereference
the next time a SMS is delivered to a route pointing to this acl,
where it will be a heap use-after-free.

This was discovered using AddressSanitizer and MSC_Tests.ttcn

Closes: OS#3168
Change-Id: I1f140d7f9c7d89f200ddbcd81a8df66de69fb3e4
2018-04-14 15:07:36 +02:00
Harald Welte a41b630ae7 cosmetic: Use msgb_hexdump*() rather than manual osmo_hexdump() on msg
This requires libosmocore Change-Id I98e85397fb541ee0fd711f2e1852f63f3bb87359

Change-Id: Ieeb97a9f1eba2fdef84294b8c8c7ac0984ae5c70
2018-02-09 02:22:09 +01:00
the 34c3 gsm team cfab83e642 smpp_smsc.c: don't talloc_strdup NULL pointers
Change-Id: Ie6a83a20464a959cf51f999d6f900fa4516ced1b
2018-01-07 19:04:10 +01:00
Neels Hofmeyr 26c218d0e7 smpp_smsc: fix truncated string copy into bind_r.system_id
The target buffer in libsmpp is 16 bytes long, and snprintf() may omit the
terminating zero. There seems to be no handling for unterminated strings, so
osmo_strlcpy() is the safer (and presumably more optimal) choice.

Change-Id: I5845666201f945ea9f83da62f2dd4bec52eb74cf
2017-12-20 15:49:38 +00:00
Neels Hofmeyr 9084396467 rename include/openbsc to include/osmocom/msc
Change-Id: I1f96a1285bbd1b4607614856bca935d5c26e2da9
2017-09-06 16:41:25 +02:00
Benoit Bolsee d34ed5768c smpp: fix return cause
Return cause 38 when default SMPP route is unavailable. This
is better than cause 1.

Change-Id: If3241d50a78fa611981e55fef6ae4c72b0a2a167
2017-08-27 02:33:47 +02:00
Pau Espin 95606647ef smpp_smsc.c: Log on sending deliver_sm message
Change-Id: Ie16294df6d5bc0065f8d2b49320ead61f535f271
2017-08-27 02:33:47 +02:00
Neels Hofmeyr 29b9206e80 move openbsc/* to repos root
This is the first step in creating this repository from the legacy openbsc.git.

Like all other Osmocom repositories, keep the autoconf and automake files in
the repository root. openbsc.git has been the sole exception, which ends now.

Change-Id: I9c6f2a448d9cb1cc088cf1cf6918b69d7e69b4e7
2017-07-12 23:17:10 +00:00