From 3088cdbb0fcefe324b0c480110f7ad880d8dabf3 Mon Sep 17 00:00:00 2001 From: Andre Puschmann Date: Sun, 13 Sep 2020 20:27:10 +0200 Subject: [PATCH] ttcn3: fix uncaught exception in SS fix accessing child element in parsed Json without checking its existence. --- srsue/test/ttcn3/hdr/ttcn3_drb_interface.h | 23 +++++++++++++--------- srsue/test/ttcn3/hdr/ttcn3_sys_interface.h | 12 ++++++----- 2 files changed, 21 insertions(+), 14 deletions(-) diff --git a/srsue/test/ttcn3/hdr/ttcn3_drb_interface.h b/srsue/test/ttcn3/hdr/ttcn3_drb_interface.h index 082acd1e2..989ad2136 100644 --- a/srsue/test/ttcn3/hdr/ttcn3_drb_interface.h +++ b/srsue/test/ttcn3/hdr/ttcn3_drb_interface.h @@ -104,15 +104,20 @@ private: ++itr) { assert(itr->HasMember("PduSduList")); assert((*itr)["PduSduList"].IsObject()); - assert((*itr)["PduSduList"].HasMember("PdcpSdu")); - assert((*itr)["PduSduList"]["PdcpSdu"].IsArray()); - const Value& sdulist = (*itr)["PduSduList"]["PdcpSdu"]; - for (Value::ConstValueIterator sdu_itr = sdulist.Begin(); sdu_itr != sdulist.End(); ++sdu_itr) { - assert(sdu_itr->IsString()); - string sdustr = sdu_itr->GetString(); - asn1::dyn_octstring octstr(sdustr.size()); - octstr.from_string(sdustr); - handle_sdu(document, lcid, octstr.data(), octstr.size(), ttcn3_helpers::get_follow_on_flag(document)); + if ((*itr)["PduSduList"].HasMember("PdcpSdu")) { + assert((*itr)["PduSduList"]["PdcpSdu"].IsArray()); + const Value& sdulist = (*itr)["PduSduList"]["PdcpSdu"]; + for (Value::ConstValueIterator sdu_itr = sdulist.Begin(); sdu_itr != sdulist.End(); ++sdu_itr) { + assert(sdu_itr->IsString()); + string sdustr = sdu_itr->GetString(); + asn1::dyn_octstring octstr(sdustr.size()); + octstr.from_string(sdustr); + handle_sdu(document, lcid, octstr.data(), octstr.size(), ttcn3_helpers::get_follow_on_flag(document)); + } + } else if ((*itr)["PduSduList"].HasMember("MacPdu")) { + log->warning("Not handling MacPdu type."); + } else { + log->warning("Not handling this PduSdu type.\n"); } } diff --git a/srsue/test/ttcn3/hdr/ttcn3_sys_interface.h b/srsue/test/ttcn3/hdr/ttcn3_sys_interface.h index 436bc2da6..3e007970e 100644 --- a/srsue/test/ttcn3/hdr/ttcn3_sys_interface.h +++ b/srsue/test/ttcn3/hdr/ttcn3_sys_interface.h @@ -374,11 +374,13 @@ private: const Value& config = (*itr)["Config"]; if (config.HasMember("AddOrReconfigure")) { const Value& aor = config["AddOrReconfigure"]; - uint32_t lcid = aor["LogicalChannelId"].GetInt(); - if (lcid > 0) { - pdcp_config_t pdcp_cfg = make_drb_pdcp_config_t(static_cast(lcid), false); - syssim->add_drb( - ttcn3_helpers::get_timing_info(document), ttcn3_helpers::get_cell_name(document), lcid, pdcp_cfg); + if (aor.HasMember("LogicalChannelId")) { + uint32_t lcid = aor["LogicalChannelId"].GetInt(); + if (lcid > 0) { + pdcp_config_t pdcp_cfg = make_drb_pdcp_config_t(static_cast(lcid), false); + syssim->add_drb( + ttcn3_helpers::get_timing_info(document), ttcn3_helpers::get_cell_name(document), lcid, pdcp_cfg); + } } } else if (config.HasMember("Release")) { uint32_t lcid = id["Drb"].GetInt() + 2;