[Asterisk-code-review] chan sip: Check sip pvt pointer in ast channel get t38 state(c) (asterisk[master])

Filip Jenicek asteriskteam at digium.com
Tue Dec 8 06:33:43 CST 2015


Filip Jenicek has posted comments on this change.

Change subject: chan_sip: Check sip_pvt pointer in ast_channel_get_t38_state(c)
......................................................................


Patch Set 1:

Hi,

I'm not exactly sure when or why it happens. 

I have experienced a crash in the sip_queryoption function. The crash happened because ast_channel_tech_pvt returned null, yet the channel was still in the channels list, and channel->tech was set to sip.

I was iterating all channels using ast_channel_iterator_all_new() and ast_channel_iterator_next(iter) and locked each channel before calling ast_channel_get_t38_state().

I compared sip_queryoption with other functions calling ast_channel_tech_pvt() and discovered, that quite a number of them checks the returned pointer for validity. The sip_queryoption didn't, so that's why I added the check.

ast_channel:
(gdb) print *chan
$4 = {
  tech = 0xb5b25ce0 <sip_tech>, 
  tech_pvt = 0x0, 
  music_state = 0x0, 
  generatordata = 0x0, 
  generator = 0x0, 
  masq = 0x0, 
  masqr = 0x0, 
  blockproc = 0x8297751 <__PRETTY_FUNCTION__.19705> "ast_waitfor_nandfds", 
  appl = 0xb590d0af "AppDial", 
  data = 0xb590d0b7 "(Outgoing Line)", 
  sched = 0x0, 
  stream = 0x0, 
  vstream = 0x0, 
  timingfunc = 0x0, 
  timingdata = 0x0, 
  pbx = 0x0, 
  writetrans = 0x0, 
  readtrans = 0x0, 
  audiohooks = 0x0, 
  framehooks = 0x0, 
  cdr = 0x0, 
  zone = 0x8cf72ec, 
  monitor = 0x0, 
  callid = 0xb6ceb80c, 
  dialed_causes = 0xb52ea4dc, 
  __field_mgr_pool = 0xb530ced8, 
  name = 0xb530ceea "SIP/i-a-outbound-0000000e", 
  language = 0xb530cf16 "en_US", 
  musicclass = 0xb530cf1e "moh_0", 
  latest_musicclass = 0x83323c2 <__ast_string_field_empty_buffer+2> "", 
  accountcode = 0x83323c2 <__ast_string_field_empty_buffer+2> "", 
  peeraccount = 0x83323c2 <__ast_string_field_empty_buffer+2> "", 
  userfield = 0x83323c2 <__ast_string_field_empty_buffer+2> "", 
  call_forward = 0x83323c2 <__ast_string_field_empty_buffer+2> "", 
  parkinglot = 0xb530cf0c "default", 
  hangupsource = 0x83323c2 <__ast_string_field_empty_buffer+2> "", 
  dialcontext = 0xb530cf26 "sub-outgoingInterface-i-a", 
  __field_mgr = {
    last_alloc = 0xb530cf26 "sub-outgoingInterface-i-a", 
    embedded_pool = 0x0
  }, 
  uniqueid = {
    creation_time = 1449070326, 
    creation_unique = 18, 
    unique_id = "1449070326.18", '\000' <repeats 138 times>
  }, 
  linkedid = {
    creation_time = 1449070322, 
    creation_unique = 13, 
    unique_id = "1449070322.13", '\000' <repeats 138 times>
  }, 
  requestorid = {
    creation_time = 1449070326, 
    creation_unique = 17, 
    unique_id = "1449070326.17", '\000' <repeats 138 times>
  }, 
  whentohangup = {
    tv_sec = 0, 
    tv_usec = 0
  }, 
  blocker = 3036560192, 
  dialed = {
    number = {
      str = 0x0, 
      plan = 0
    }, 
    subaddress = {
      str = 0x0, 
      type = 0, 
      odd_even_indicator = 0 '\000', 

      valid = 0 '\000'
    }, 
    transit_network_select = 0
  }, 
  caller = {
    id = {
      name = {
        str = 0xb54fc330 "Link Tel", 
        char_set = 1, 
        presentation = 0, 
        valid = 1 '\001'
      }, 
      number = {
        str = 0xb53c49c8 "s", 
        plan = 0, 
        presentation = 0, 
        valid = 1 '\001'
      }, 
      subaddress = {
        str = 0x0, 
        type = 0, 
        odd_even_indicator = 0 '\000', 
        valid = 0 '\000'
      }, 
      tag = 0xb532c198 ""
    }, 
    ani = {
      name = {
        str = 0x0, 
        char_set = 1, 
        presentation = 0, 
        valid = 0 '\000'
      }, 
      number = {
        str = 0x0, 
        plan = 0, 
        presentation = 0, 
        valid = 0 '\000'
      }, 
      subaddress = {
        str = 0x0, 
        type = 0, 
        odd_even_indicator = 0 '\000', 
        valid = 0 '\000'
      }, 
      tag = 0x0
    }, 
    priv = {
      name = {
        str = 0x0, 
        char_set = 1, 
        presentation = 0, 
        valid = 0 '\000'
      }, 
      number = {
        str = 0x0, 
        plan = 0, 
        presentation = 0, 
        valid = 0 '\000'
      }, 
      subaddress = {
        str = 0x0, 
        type = 0, 
        odd_even_indicator = 0 '\000', 
        valid = 0 '\000'
      }, 
      tag = 0x0
    }, 
    ani2 = 0
  }, 
  connected = {
    id = {
      name = {
        str = 0xb6c41e30 "Link Tel", 
        char_set = 1, 
        presentation = 3, 
        valid = 1 '\001'
      }, 
      number = {
        str = 0xb5339988 "+098798798765420", 
        plan = 0, 
        presentation = 3, 
        valid = 1 '\001'
      }, 
      subaddress = {
        str = 0x0, 
        type = 0, 
        odd_even_indicator = 0 '\000', 
        valid = 0 '\000'
      }, 
      tag = 0xb529d4c0 ""
    }, 
    ani = {
      name = {
        str = 0x0, 
        char_set = 1, 
        presentation = 0, 
        valid = 0 '\000'
      }, 
      number = {
        str = 0xb541aa78 "10", 
        plan = 0, 
        presentation = 0, 
        valid = 1 '\001'
      }, 
      subaddress = {
        str = 0x0, 
        type = 0, 
        odd_even_indicator = 0 '\000', 
        valid = 0 '\000'
      }, 
      tag = 0x0
    }, 
    priv = {
      name = {
        str = 0x0, 
        char_set = 1, 
        presentation = 0, 
        valid = 0 '\000'
      }, 
      number = {
        str = 0x0, 
        plan = 0, 
        presentation = 0, 
        valid = 0 '\000'
      }, 
      subaddress = {
        str = 0x0, 
        type = 0, 
        odd_even_indicator = 0 '\000', 
        valid = 0 '\000'
      }, 
      tag = 0x0
    }, 
    ani2 = 0, 
    source = 0
  }, 
  connected_indicated = {
    id = {
      name = {
        str = 0x0, 
        char_set = 1, 

        presentation = 0, 
        valid = 0 '\000'
      }, 
      number = {
        str = 0x0, 
        plan = 0, 
        presentation = 0, 
        valid = 0 '\000'
      }, 
      subaddress = {
        str = 0x0, 
        type = 0, 
        odd_even_indicator = 0 '\000', 
        valid = 0 '\000'
      }, 
      tag = 0x0
    }, 
    ani = {
      name = {
        str = 0x0, 
        char_set = 1, 
        presentation = 0, 
        valid = 0 '\000'
      }, 
      number = {
        str = 0x0, 
        plan = 0, 
        presentation = 0, 
        valid = 0 '\000'
      }, 
      subaddress = {
        str = 0x0, 
        type = 0, 
        odd_even_indicator = 0 '\000', 
        valid = 0 '\000'
      }, 
      tag = 0x0
    }, 
    priv = {
      name = {
        str = 0x0, 
        char_set = 1, 
        presentation = 0, 
        valid = 0 '\000'
      }, 
      number = {
        str = 0x0, 
        plan = 0, 
        presentation = 0, 
        valid = 0 '\000'
      }, 
      subaddress = {
        str = 0x0, 
        type = 0, 
        odd_even_indicator = 0 '\000', 
        valid = 0 '\000'
      }, 
      tag = 0x0
    }, 
    ani2 = 0, 
    source = 0
  }, 
  redirecting = {
    orig = {
      name = {
        str = 0x0, 
        char_set = 1, 
        presentation = 0, 
        valid = 0 '\000'
      }, 
      number = {
        str = 0x0, 
        plan = 0, 
        presentation = 0, 
        valid = 0 '\000'
      }, 
      subaddress = {
        str = 0x0, 
        type = 0, 
        odd_even_indicator = 0 '\000', 
        valid = 0 '\000'
      }, 
      tag = 0x0
    }, 
    from = {
      name = {
        str = 0x0, 
        char_set = 1, 
        presentation = 0, 
        valid = 0 '\000'
      }, 
      number = {
        str = 0x0, 
        plan = 0, 
        presentation = 0, 
        valid = 0 '\000'
      }, 
      subaddress = {
        str = 0x0, 
        type = 0, 
        odd_even_indicator = 0 '\000', 
        valid = 0 '\000'
      }, 
      tag = 0x0
    }, 
    to = {
      name = {
        str = 0x0, 
        char_set = 1, 
        presentation = 0, 
        valid = 0 '\000'
      }, 
      number = {
        str = 0x0, 
        plan = 0, 
        presentation = 0, 
        valid = 0 '\000'
      }, 
      subaddress = {
        str = 0x0, 
        type = 0, 
        odd_even_indicator = 0 '\000', 
        valid = 0 '\000'
      }, 
      tag = 0x0
    }, 
    priv_orig = {
      name = {
        str = 0x0, 
        char_set = 1, 
        presentation = 0, 
        valid = 0 '\000'
      }, 
      number = {
        str = 0x0, 
        plan = 0, 
        presentation = 0, 
        valid = 0 '\000'
      }, 
      subaddress = {
        str = 0x0, 
        type = 0, 

        odd_even_indicator = 0 '\000', 
        valid = 0 '\000'
      }, 
      tag = 0x0
    }, 
    priv_from = {
      name = {
        str = 0x0, 
        char_set = 1, 
        presentation = 0, 
        valid = 0 '\000'
      }, 
      number = {
        str = 0x0, 
        plan = 0, 
        presentation = 0, 
        valid = 0 '\000'
      }, 
      subaddress = {
        str = 0x0, 
        type = 0, 
        odd_even_indicator = 0 '\000', 
        valid = 0 '\000'
      }, 
      tag = 0x0
    }, 
    priv_to = {
      name = {
        str = 0x0, 
        char_set = 1, 
        presentation = 0, 
        valid = 0 '\000'
      }, 
      number = {
        str = 0x0, 
        plan = 0, 
        presentation = 0, 
        valid = 0 '\000'
      }, 
      subaddress = {
        str = 0x0, 
        type = 0, 
        odd_even_indicator = 0 '\000', 
        valid = 0 '\000'
      }, 
      tag = 0x0
    }, 
    reason = {
      str = 0x0, 
      code = 0
    }, 
    orig_reason = {
      str = 0x0, 
      code = 0
    }, 
    count = 0
  }, 
  dtmff = {
    frametype = 0, 
    subclass = {
      integer = 0, 
      format = 0x0, 
      frame_ending = 0
    }, 
    datalen = 0, 
    samples = 0, 
    mallocd = 0, 
    mallocd_hdr_len = 0, 
    offset = 0, 
    src = 0x0, 
    data = {

      ptr = 0x0, 
      uint32 = 0, 
      pad = "\000\000\000\000\000\000\000"
    }, 
    delivery = {
      tv_sec = 0, 
      tv_usec = 0
    }, 
    frame_list = {
      next = 0x0
    }, 
    flags = 0, 
    ts = 0, 
    len = 0, 
    seqno = 0
  }, 
  varshead = {
    first = 0xb6c824f0, 
    last = 0xb54334c0
  }, 
  callgroup = 0, 
  pickupgroup = 0, 
  named_callgroups = 0x0, 
  named_pickupgroups = 0x0, 
  creationtime = {
    tv_sec = 1449070326, 
    tv_usec = 867047
  }, 
  answertime = {
    tv_sec = 0, 
    tv_usec = 0
  }, 
  readq = {
    first = 0x0, 
    last = 0x0
  }, 
  jb = {
    conf = {
      flags = 0, 
      max_size = 200, 
      resync_threshold = 1000, 
      impl = "fixed\000\000\000\000\000\000", 
      target_extra = 40
    }, 
    impl = 0x0, 
    jbobj = 0x0, 
    timebase = {
      tv_sec = 0, 
      tv_usec = 0
    }, 
    next = 0, 
    last_format = 0x0, 
    logfile = 0x0, 
    flags = 0
  }, 
  dtmf_tv = {
    tv_sec = 0, 
    tv_usec = 0
  }, 
  hangup_handlers = {
    first = 0x0, 
    last = 0x0
  }, 
  datastores = {
    first = 0xb54f91a8, 
    last = 0xb4e34408
  }, 
  autochans = {
    first = 0x0, 
    last = 0x0
  }, 
  insmpl = 0, 
  outsmpl = 0, 
  fds = {29, 30, -1, -1, -1, -1, -1, -1, -1, 31, 41}, 
  softhangup = 0, 
  unbridged = 0, 
  fdno = 0, 
  streamid = -1, 
  vstreamid = 0, 
  oldwriteformat = 0x0, 
  timingfd = 31, 
  state = AST_STATE_DOWN, 
  rings = 0, 
  priority = 1, 
  macropriority = 0, 
  amaflags = 3, 
  adsicpe = AST_ADSI_UNKNOWN, 
  fin = 0, 
  fout = 0, 
  hangupcause = 0, 
  finalized = 1, 
  flags = {
    flags = 1040
  }, 
  alertpipe = {41, 42}, 
  nativeformats = 0xb529f1fc, 
  readformat = 0x869578c, 
  writeformat = 0x869578c, 
  rawreadformat = 0x869578c, 
  rawwriteformat = 0x869578c, 
  emulate_dtmf_duration = 0, 
  visible_indication = 0, 
  hold_state = 17, 
  transfercapability = 0, 
  bridge = 0x0, 
  bridge_channel = 0x0, 
  timer = 0xb538a6a0, 
  context = "i-bender.kerio.local", '\000' <repeats 59 times>, 
  exten = "s", '\000' <repeats 78 times>, 
  macrocontext = '\000' <repeats 79 times>, 
  macroexten = '\000' <repeats 79 times>, 
  dtmf_digit_to_emulate = 0 '\000', 
  sending_dtmf_digit = 0 '\000', 
  sending_dtmf_tv = {
    tv_sec = 0, 
    tv_usec = 0
  }, 
  topics = 0xb54c9d94, 
  endpoint_forward = 0xb543ce3c, 
  endpoint_cache_forward = 0xb539e3cc
}

-- 
To view, visit https://gerrit.asterisk.org/1776
To unsubscribe, visit https://gerrit.asterisk.org/settings

Gerrit-MessageType: comment
Gerrit-Change-Id: Ifaa707c04b865a290ffab719bd2e5c48ff667c7b
Gerrit-PatchSet: 1
Gerrit-Project: asterisk
Gerrit-Branch: master
Gerrit-Owner: Filip Jenicek <phill at janevim.cz>
Gerrit-Reviewer: Anonymous Coward #1000019
Gerrit-Reviewer: Filip Jenicek <phill at janevim.cz>
Gerrit-Reviewer: Joshua Colp <jcolp at digium.com>
Gerrit-HasComments: No



More information about the asterisk-code-review mailing list