From 0714002e28366a063d3e484212f8614a3d3922f2 Mon Sep 17 00:00:00 2001 From: Neels Hofmeyr Date: Mon, 15 Apr 2019 13:46:44 +0200 Subject: smpp: fix vlr_subscr use count bugs In smpp_openbsc.c submit_to_sms(), "get" the appropriate use count upon assigning sms->receiver, fixing a -1 use count upon sms_free(). Also, avoid a "put" of a NULL subscriber in the same function. Related: OS#3930 Change-Id: Idaf01cd3cfa08088ce0d543d0576db957dc94262 --- src/libmsc/smpp_openbsc.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/libmsc/smpp_openbsc.c b/src/libmsc/smpp_openbsc.c index 01c39f906..151c788b2 100644 --- a/src/libmsc/smpp_openbsc.c +++ b/src/libmsc/smpp_openbsc.c @@ -139,7 +139,8 @@ static int submit_to_sms(struct gsm_sms **psms, struct gsm_network *net, } else { LOGP(DLSMS, LOGL_ERROR, "SMPP neither message payload nor valid sm_length.\n"); - vlr_subscr_put(dest, VSUB_USE_SMPP); + if (dest) + vlr_subscr_put(dest, VSUB_USE_SMPP); return ESME_RINVPARLEN; } } @@ -152,6 +153,12 @@ static int submit_to_sms(struct gsm_sms **psms, struct gsm_network *net, /* fill in the destination address */ sms->receiver = dest; + if (dest) { + /* Replace use count from above subscr_by_dst (VSUB_USE_SMPP) by the sms->receiver use count + * (VSUB_USE_SMS_RECEIVER) */ + vlr_subscr_get(sms->receiver, VSUB_USE_SMS_RECEIVER); + vlr_subscr_put(dest, VSUB_USE_SMPP); + } sms->dst.ton = submit->dest_addr_ton; sms->dst.npi = submit->dest_addr_npi; if (dest) -- cgit v1.2.3