nitb: Add a missing NULL check for searching the subscriber

"subscriber " SUBSCR_TYPES " ID sms pending-send

could fail with an invalid ID/IMSI for the subscriber.

Fixes: Coverity CID 1040715
This commit is contained in:
Holger Hans Peter Freyther 2013-07-04 20:34:46 +02:00
parent e885951f27
commit 9feef48eaf
1 changed files with 8 additions and 1 deletions

View File

@ -216,9 +216,16 @@ DEFUN(subscriber_send_pending_sms,
SUBSCR_HELP "SMS Operations\n" "Send pending SMS\n")
{
struct gsm_network *gsmnet = gsmnet_from_vty(vty);
struct gsm_subscriber *subscr = get_subscr_by_argv(gsmnet, argv[0], argv[1]);
struct gsm_subscriber *subscr;
struct gsm_sms *sms;
subscr = get_subscr_by_argv(gsmnet, argv[0], argv[1]);
if (!subscr) {
vty_out(vty, "%% No subscriber found for %s %s%s",
argv[0], argv[1], VTY_NEWLINE);
return CMD_WARNING;
}
sms = db_sms_get_unsent_by_subscr(gsmnet, subscr->id, UINT_MAX);
if (sms)
gsm411_send_sms_subscr(sms->receiver, sms);