From 17cb3ec57b3b9dd537fea4d156384623360d1ae8 Mon Sep 17 00:00:00 2001 From: Johnny Willemsen Date: Mon, 9 Apr 2018 18:30:56 +0200 Subject: Add some more error logic for the cases the create_profile fails * TAO/tao/Connector_Registry.cpp: --- TAO/tao/Connector_Registry.cpp | 37 +++++++++++++++++++++++++++++++------ 1 file changed, 31 insertions(+), 6 deletions(-) (limited to 'TAO/tao/Connector_Registry.cpp') diff --git a/TAO/tao/Connector_Registry.cpp b/TAO/tao/Connector_Registry.cpp index 0f828f613b1..8d3d2eece02 100644 --- a/TAO/tao/Connector_Registry.cpp +++ b/TAO/tao/Connector_Registry.cpp @@ -165,8 +165,13 @@ TAO_Connector_Registry::create_profile (TAO_InputCDR &cdr) CORBA::ULong tag = 0; // If there is an error we abort. - if ((cdr >> tag) == 0) + if (!(cdr >> tag)) + { + TAOLIB_ERROR ((LM_ERROR, + ACE_TEXT ("TAO (%P|%t) - TAO_Connector_Registry::") + ACE_TEXT ("create_profile: Unable to extract tag from CDR stream\n"))); return 0; + } TAO_Connector *connector = this->get_connector (tag); @@ -195,7 +200,6 @@ TAO_Connector_Registry::create_profile (TAO_InputCDR &cdr) } } - TAO_Profile *pfile = 0; ACE_NEW_RETURN (pfile, TAO_Unknown_Profile (tag, @@ -203,6 +207,9 @@ TAO_Connector_Registry::create_profile (TAO_InputCDR &cdr) 0); if (pfile->decode (cdr) == -1) { + TAOLIB_ERROR ((LM_ERROR, + ACE_TEXT ("TAO (%P|%t) - TAO_Connector_Registry::") + ACE_TEXT ("create_profile: Unable to decode unknown profile from CDR stream\n"))); pfile->_decr_refcnt (); pfile = 0; } @@ -217,18 +224,36 @@ TAO_Connector_Registry::create_profile (TAO_InputCDR &cdr) // ProfileData is encoded as a sequence of octet. So first get the // length of the sequence. CORBA::ULong encap_len = 0; - if ((cdr >> encap_len) == 0) + if (!(cdr >> encap_len)) + { + TAOLIB_ERROR ((LM_ERROR, + ACE_TEXT ("TAO (%P|%t) - TAO_Connector_Registry::") + ACE_TEXT ("create_profile: Unable to extract encapsulated length from CDR stream\n"))); return 0; + } // Create the decoding stream from the encapsulation in the buffer, // and skip the encapsulation. TAO_InputCDR str (cdr, encap_len); - if (str.good_bit () == 0 - || cdr.skip_bytes (encap_len) == 0) + if (!str.good_bit () || !cdr.skip_bytes (encap_len)) + { + TAOLIB_ERROR ((LM_ERROR, + ACE_TEXT ("TAO (%P|%t) - TAO_Connector_Registry::") + ACE_TEXT ("create_profile: Unable to skip encapsulated stream from CDR stream\n"))); return 0; + } + + TAO_Profile* profile = connector->create_profile (str); + + if (!profile) + { + TAOLIB_ERROR ((LM_ERROR, + ACE_TEXT ("TAO (%P|%t) - TAO_Connector_Registry::") + ACE_TEXT ("create_profile: Connector returned null profile for tag 0x%x\n"), tag)); + } - return connector->create_profile (str); + return profile; } char -- cgit v1.2.1