diff options
50 files changed, 554 insertions, 314 deletions
diff --git a/TAO/tao/Acceptor_Registry.cpp b/TAO/tao/Acceptor_Registry.cpp index ad580794443..1b3480e4505 100644 --- a/TAO/tao/Acceptor_Registry.cpp +++ b/TAO/tao/Acceptor_Registry.cpp @@ -397,6 +397,10 @@ int TAO_Acceptor_Registry::open_default (TAO_ORB_Core *orb_core, ACE_INET_Addr addr(static_cast<unsigned short> (0)); // IPv4 ANY TAO_IIOP_Acceptor* iiop_acceptor = dynamic_cast<TAO_IIOP_Acceptor*> (acceptor); + + if (!iiop_acceptor) + return -1; + iiop_acceptor->set_default_address (addr); if (this->open_default_i (orb_core, @@ -435,6 +439,10 @@ int TAO_Acceptor_Registry::open_default (TAO_ORB_Core *orb_core, addr.set (port, ACE_IPV6_ANY, AF_INET6); // IPv6 ANY on specified port iiop_acceptor = dynamic_cast<TAO_IIOP_Acceptor*> (acceptor); + + if (!iiop_acceptor) + return -1; + iiop_acceptor->set_default_address (addr); if (this->open_default_i (orb_core, @@ -730,6 +738,10 @@ TAO_Acceptor_Registry::open_i (TAO_ORB_Core *orb_core, ACE_INET_Addr addr(static_cast<unsigned short> (0)); // IPv4 ANY TAO_IIOP_Acceptor* iiop_acceptor = dynamic_cast<TAO_IIOP_Acceptor*> (acceptor); + + if (!iiop_acceptor) + return -1; + iiop_acceptor->set_default_address (addr); if (this->open_default_i (orb_core, @@ -769,6 +781,9 @@ TAO_Acceptor_Registry::open_i (TAO_ORB_Core *orb_core, addr.set (port, ACE_IPV6_ANY, AF_INET6); // IPv6 ANY on specified port iiop_acceptor = dynamic_cast<TAO_IIOP_Acceptor*> (acceptor); + if (!iiop_acceptor) + return -1; + iiop_acceptor->set_default_address (addr); if (this->open_default_i (orb_core, diff --git a/TAO/tao/AnyTypeCode/Any_Basic_Impl.cpp b/TAO/tao/AnyTypeCode/Any_Basic_Impl.cpp index 3c251f5f23a..2084f935aa1 100644 --- a/TAO/tao/AnyTypeCode/Any_Basic_Impl.cpp +++ b/TAO/tao/AnyTypeCode/Any_Basic_Impl.cpp @@ -101,7 +101,7 @@ namespace TAO try { CORBA::TypeCode_ptr any_tc = any._tao_get_typecode (); - CORBA::Boolean _tao_equiv = + CORBA::Boolean const _tao_equiv = any_tc->equivalent (tc); if (!_tao_equiv) @@ -109,11 +109,11 @@ namespace TAO return false; } - TAO::Any_Impl *impl = any.impl (); + TAO::Any_Impl * const impl = any.impl (); - if (!impl->encoded ()) + if (impl && !impl->encoded ()) { - TAO::Any_Basic_Impl *narrow_impl = + TAO::Any_Basic_Impl * const narrow_impl = dynamic_cast<TAO::Any_Basic_Impl *> (impl); if (narrow_impl == 0) @@ -131,9 +131,12 @@ namespace TAO auto_ptr<TAO::Any_Basic_Impl> replacement_safety (replacement); // We know this will work since the unencoded case is covered above. - TAO::Unknown_IDL_Type *unk = + TAO::Unknown_IDL_Type * const unk = dynamic_cast<TAO::Unknown_IDL_Type *> (impl); + if (!unk) + return false; + // Get the kind of the type where we are extracting in ie. the // aliased type if there are any. Passing the aliased kind // will not help. @@ -170,7 +173,7 @@ namespace TAO CORBA::Boolean Any_Basic_Impl::marshal_value (TAO_OutputCDR &cdr) { - CORBA::TCKind tckind = static_cast<CORBA::TCKind> (this->kind_); + CORBA::TCKind const tckind = static_cast<CORBA::TCKind> (this->kind_); switch (tckind) { @@ -203,7 +206,7 @@ namespace TAO case CORBA::tk_wchar: return cdr << CORBA::Any::from_wchar (this->u_.wc); default: - return 0; + return false; } } diff --git a/TAO/tao/AnyTypeCode/Any_Basic_Impl_T.cpp b/TAO/tao/AnyTypeCode/Any_Basic_Impl_T.cpp index 82b5321558c..185d8915034 100644 --- a/TAO/tao/AnyTypeCode/Any_Basic_Impl_T.cpp +++ b/TAO/tao/AnyTypeCode/Any_Basic_Impl_T.cpp @@ -55,18 +55,17 @@ TAO::Any_Basic_Impl_T<T>::extract (const CORBA::Any & any, { CORBA::TypeCode_ptr any_tc = any._tao_get_typecode (); CORBA::Boolean const _tao_equiv = any_tc->equivalent (tc); - if (_tao_equiv == false) { return false; } - TAO::Any_Impl *impl = any.impl (); + TAO::Any_Impl * const impl = any.impl (); - if (!impl->encoded ()) + if (impl && !impl->encoded ()) { - TAO::Any_Basic_Impl_T<T> *narrow_impl = - dynamic_cast <TAO::Any_Basic_Impl_T<T> *> (impl); + TAO::Any_Basic_Impl_T<T> * const narrow_impl = + dynamic_cast<TAO::Any_Basic_Impl_T<T> *> (impl); if (narrow_impl == 0) { @@ -77,15 +76,18 @@ TAO::Any_Basic_Impl_T<T>::extract (const CORBA::Any & any, return true; } - TAO::Any_Basic_Impl_T<T> *replacement = + TAO::Any_Basic_Impl_T<T> * const replacement = TAO::Any_Basic_Impl_T<T>::create_empty (any_tc); auto_ptr<TAO::Any_Basic_Impl_T<T> > replacement_safety (replacement); // We know this will work since the unencoded case is covered above. - TAO::Unknown_IDL_Type *unk = + TAO::Unknown_IDL_Type * const unk = dynamic_cast<TAO::Unknown_IDL_Type *> (impl); + if (!unk) + return false; + // We don't want the rd_ptr of unk to move, in case it is // shared by another Any. This copies the state, not the buffer. TAO_InputCDR for_reading (unk->_tao_get_cdr ()); diff --git a/TAO/tao/AnyTypeCode/Any_Dual_Impl_T.cpp b/TAO/tao/AnyTypeCode/Any_Dual_Impl_T.cpp index 4777ae696b9..e43cfaffc26 100644 --- a/TAO/tao/AnyTypeCode/Any_Dual_Impl_T.cpp +++ b/TAO/tao/AnyTypeCode/Any_Dual_Impl_T.cpp @@ -102,18 +102,18 @@ TAO::Any_Dual_Impl_T<T>::extract (const CORBA::Any & any, try { CORBA::TypeCode_ptr any_tc = any._tao_get_typecode (); - CORBA::Boolean _tao_equiv = any_tc->equivalent (tc); + CORBA::Boolean const _tao_equiv = any_tc->equivalent (tc); if (_tao_equiv == false) { return false; } - TAO::Any_Impl *impl = any.impl (); + TAO::Any_Impl * const impl = any.impl (); - if (!impl->encoded ()) + if (impl && !impl->encoded ()) { - TAO::Any_Dual_Impl_T<T> *narrow_impl = + TAO::Any_Dual_Impl_T<T> * const narrow_impl = dynamic_cast <TAO::Any_Dual_Impl_T<T> *> (impl); if (narrow_impl == 0) @@ -139,9 +139,12 @@ TAO::Any_Dual_Impl_T<T>::extract (const CORBA::Any & any, auto_ptr<TAO::Any_Dual_Impl_T<T> > replacement_safety (replacement); // We know this will work since the unencoded case is covered above. - TAO::Unknown_IDL_Type *unk = + TAO::Unknown_IDL_Type * const unk = dynamic_cast<TAO::Unknown_IDL_Type *> (impl); + if (!unk) + return false; + // We don't want the rd_ptr of unk to move, in case it is // shared by another Any. This copies the state, not the buffer. TAO_InputCDR for_reading (unk->_tao_get_cdr ()); diff --git a/TAO/tao/AnyTypeCode/Any_Impl_T.cpp b/TAO/tao/AnyTypeCode/Any_Impl_T.cpp index 332298de8c1..b6ac3bd2724 100644 --- a/TAO/tao/AnyTypeCode/Any_Impl_T.cpp +++ b/TAO/tao/AnyTypeCode/Any_Impl_T.cpp @@ -61,18 +61,18 @@ TAO::Any_Impl_T<T>::extract (const CORBA::Any & any, try { CORBA::TypeCode_ptr any_tc = any._tao_get_typecode (); - CORBA::Boolean _tao_equiv = any_tc->equivalent (tc); + CORBA::Boolean const _tao_equiv = any_tc->equivalent (tc); if (_tao_equiv == 0) { return false; } - TAO::Any_Impl *impl = any.impl (); + TAO::Any_Impl * const impl = any.impl (); - if (!impl->encoded ()) + if (impl && !impl->encoded ()) { - TAO::Any_Impl_T<T> *narrow_impl = + TAO::Any_Impl_T<T> * const narrow_impl = dynamic_cast <TAO::Any_Impl_T<T> *> (impl); if (narrow_impl == 0) @@ -94,9 +94,12 @@ TAO::Any_Impl_T<T>::extract (const CORBA::Any & any, auto_ptr<TAO::Any_Impl_T<T> > replacement_safety (replacement); // We know this will work since the unencoded case is covered above. - TAO::Unknown_IDL_Type *unk = + TAO::Unknown_IDL_Type * const unk = dynamic_cast<TAO::Unknown_IDL_Type *> (impl); + if (!unk) + return false; + // We don't want the rd_ptr of unk to move, in case it is // shared by another Any. This copies the state, not the buffer. TAO_InputCDR for_reading (unk->_tao_get_cdr ()); @@ -126,14 +129,14 @@ template<typename T> CORBA::Boolean TAO::Any_Impl_T<T>::to_object (CORBA::Object_ptr &) const { - return 0; + return false; } template<typename T> CORBA::Boolean TAO::Any_Impl_T<T>::to_value (CORBA::ValueBase *&) const { - return 0; + return false; } template<typename T> @@ -141,7 +144,7 @@ template<typename T> CORBA::Boolean TAO::Any_Impl_T<T>::to_abstract_base (CORBA::AbstractBase_ptr &) const { - return 0; + return false; } template<typename T> diff --git a/TAO/tao/AnyTypeCode/Any_Special_Impl_T.cpp b/TAO/tao/AnyTypeCode/Any_Special_Impl_T.cpp index 9f6fb90199d..05dbc43b377 100644 --- a/TAO/tao/AnyTypeCode/Any_Special_Impl_T.cpp +++ b/TAO/tao/AnyTypeCode/Any_Special_Impl_T.cpp @@ -88,31 +88,31 @@ TAO::Any_Special_Impl_T<T, from_T, to_T>::extract (const CORBA::Any & any, TAO::unaliased_typecode (any_type ); - CORBA::TCKind any_kind = + CORBA::TCKind const any_kind = unaliased_any_type->kind (); - CORBA::TCKind try_kind = tc->kind (); + CORBA::TCKind const try_kind = tc->kind (); if (any_kind != try_kind) { return false; } - CORBA::ULong length = unaliased_any_type->length (); + CORBA::ULong const length = unaliased_any_type->length (); if (length != bound) { return false; } - TAO::Any_Impl *impl = any.impl (); + TAO::Any_Impl * const impl = any.impl (); typedef TAO::Any_Special_Impl_T<T, from_T, to_T> BOUNDED_TSTRING_ANY_IMPL; - if (!impl->encoded ()) + if (impl && !impl->encoded ()) { - TAO::Any_Special_Impl_T<T, from_T, to_T> *narrow_impl = + TAO::Any_Special_Impl_T<T, from_T, to_T> * const narrow_impl = dynamic_cast <BOUNDED_TSTRING_ANY_IMPL *> (impl); if (narrow_impl == 0) @@ -137,9 +137,12 @@ TAO::Any_Special_Impl_T<T, from_T, to_T>::extract (const CORBA::Any & any, ); // We know this will work since the unencoded case is covered above. - TAO::Unknown_IDL_Type *unk = + TAO::Unknown_IDL_Type * const unk = dynamic_cast<TAO::Unknown_IDL_Type *> (impl); + if (!unk) + return false; + // We don't want the rd_ptr of unk to move, in case it is // shared by another Any. This copies the state, not the buffer. TAO_InputCDR for_reading (unk->_tao_get_cdr ()); diff --git a/TAO/tao/AnyTypeCode/Any_SystemException.cpp b/TAO/tao/AnyTypeCode/Any_SystemException.cpp index 8c9853c44b0..ef44c4ff664 100644 --- a/TAO/tao/AnyTypeCode/Any_SystemException.cpp +++ b/TAO/tao/AnyTypeCode/Any_SystemException.cpp @@ -124,9 +124,12 @@ TAO::Any_SystemException::extract (const CORBA::Any & any, auto_ptr<TAO::Any_SystemException > replacement_safety (replacement); // We know this will work since the unencoded case is covered above. - TAO::Unknown_IDL_Type *unk = + TAO::Unknown_IDL_Type * const unk = dynamic_cast<TAO::Unknown_IDL_Type *> (impl); + if (!unk) + return false; + // We don't want the rd_ptr of unk to move, in case it is // shared by another Any. This copies the state, not the buffer. TAO_InputCDR for_reading (unk->_tao_get_cdr ()); diff --git a/TAO/tao/AnyTypeCode/String_TypeCode_Traits.h b/TAO/tao/AnyTypeCode/String_TypeCode_Traits.h index 670e6a835ba..2b921ddc93a 100644 --- a/TAO/tao/AnyTypeCode/String_TypeCode_Traits.h +++ b/TAO/tao/AnyTypeCode/String_TypeCode_Traits.h @@ -45,7 +45,7 @@ namespace TAO { typedef TAO::TypeCode::String<TAO::True_RefCount_Policy> typecode_type; - CORBA::TypeCode_ptr tc = CORBA::TypeCode::_nil (); + CORBA::TypeCode_ptr tc = CORBA::TypeCode_ptr (); ACE_NEW_RETURN (tc, typecode_type (kind, bound), tc); @@ -62,7 +62,7 @@ namespace TAO { typedef TAO::TypeCode::String<TAO::True_RefCount_Policy> typecode_type; - CORBA::TypeCode_ptr tc = CORBA::TypeCode::_nil (); + CORBA::TypeCode_ptr tc = CORBA::TypeCode_ptr (); ACE_NEW_RETURN (tc, typecode_type (kind, bound), tc); diff --git a/TAO/tao/AnyTypeCode/TypeCode_CDR_Extraction.cpp b/TAO/tao/AnyTypeCode/TypeCode_CDR_Extraction.cpp index bd489f01c77..a04d76ec0f9 100644 --- a/TAO/tao/AnyTypeCode/TypeCode_CDR_Extraction.cpp +++ b/TAO/tao/AnyTypeCode/TypeCode_CDR_Extraction.cpp @@ -84,7 +84,7 @@ namespace // --------------------------------------------------------- - CORBA::ULong const TYPECODE_INDIRECTION = 0xffffffff; + CORBA::ULong const TYPECODE_INDIRECTION = 0xffffffffU; // --------------------------------------------------------- @@ -120,8 +120,8 @@ namespace if (ACE_OS::strcmp (info.id, id) == 0) { - // We have a mathing id, so store the typecode in the out array - // and then compare the others. + // We have a matching id, so store the TypeCode in the out + // array and then compare the others. size_t const old_size = tcs.size (); if (tcs.size (old_size + 1) == -1) // Incremental growth -- *sigh* return false; @@ -435,7 +435,8 @@ TAO::TypeCodeFactory::tc_struct_factory (CORBA::TCKind kind, recursive_typecode_type * const rtc = dynamic_cast<recursive_typecode_type *> (info.type); - ACE_ASSERT (rtc); + if (!rtc) + return false; // Should never occur. rtc->struct_parameters (name.in (), fields, @@ -675,7 +676,7 @@ TAO::TypeCodeFactory::tc_union_factory (CORBA::TCKind /* kind */, case_array_type, TAO::True_RefCount_Policy> typecode_type; - // Check if we have recursive members, this could be multiple + // Check if we have recursive members. There could be multiple. TAO::TypeCodeFactory::TC_Info_List recursive_tc; if (find_recursive_tc (id.in (), recursive_tc, infos)) { @@ -695,7 +696,8 @@ TAO::TypeCodeFactory::tc_union_factory (CORBA::TCKind /* kind */, recursive_typecode_type * const rtc = dynamic_cast<recursive_typecode_type *> (info.type); - ACE_ASSERT (rtc); + if (!rtc) + return false; // Should never occur. rtc->union_parameters (name.in (), discriminant_type, @@ -1050,7 +1052,8 @@ TAO::TypeCodeFactory::tc_value_factory (CORBA::TCKind kind, recursive_typecode_type * const rtc = dynamic_cast<recursive_typecode_type *> (info.type); - ACE_ASSERT (rtc); + if (!rtc) + return false; // Should never occur. rtc->valuetype_parameters (name.in (), type_modifier, diff --git a/TAO/tao/AnyTypeCode/append.cpp b/TAO/tao/AnyTypeCode/append.cpp index 1723fdbcce6..7bc2b7ad644 100644 --- a/TAO/tao/AnyTypeCode/append.cpp +++ b/TAO/tao/AnyTypeCode/append.cpp @@ -535,9 +535,13 @@ TAO_Marshal_Union::append (CORBA::TypeCode_ptr tc, if (impl->encoded ()) { - TAO::Unknown_IDL_Type *unk = + TAO::Unknown_IDL_Type * const unk = dynamic_cast<TAO::Unknown_IDL_Type *> (impl); + if (!unk) + ACE_THROW_RETURN (CORBA::INTERNAL (), + TAO::TRAVERSE_STOP); + // We don't want unk's rd_ptr to move, in case // we are shared by another Any, so we use this // to copy the state, not the buffer. diff --git a/TAO/tao/AnyTypeCode/skip.cpp b/TAO/tao/AnyTypeCode/skip.cpp index f64d4700cd3..f9cb17673d0 100644 --- a/TAO/tao/AnyTypeCode/skip.cpp +++ b/TAO/tao/AnyTypeCode/skip.cpp @@ -482,9 +482,13 @@ TAO_Marshal_Union::skip (CORBA::TypeCode_ptr tc, if (impl->encoded ()) { - TAO::Unknown_IDL_Type *unk = + TAO::Unknown_IDL_Type * const unk = dynamic_cast<TAO::Unknown_IDL_Type *> (impl); + if (!unk) + ACE_THROW_RETURN (CORBA::INTERNAL (), + TAO::TRAVERSE_STOP); + // We don't want unk's rd_ptr to move, in case // we are shared by another Any, so we use this // to copy the state, not the buffer. diff --git a/TAO/tao/BiDir_GIOP/BiDir_PolicyFactory.cpp b/TAO/tao/BiDir_GIOP/BiDir_PolicyFactory.cpp index 3c4bc6e346c..03559f68670 100644 --- a/TAO/tao/BiDir_GIOP/BiDir_PolicyFactory.cpp +++ b/TAO/tao/BiDir_GIOP/BiDir_PolicyFactory.cpp @@ -18,7 +18,7 @@ TAO_BiDir_PolicyFactory::create_policy ( CORBA::PolicyType type, const CORBA::Any &value) { - CORBA::Policy_ptr policy = CORBA::Policy::_nil (); + CORBA::Policy_ptr policy = CORBA::Policy_ptr (); if (type == BiDirPolicy::BIDIRECTIONAL_POLICY_TYPE) { diff --git a/TAO/tao/CSD_ThreadPool/CSD_TP_Task.cpp b/TAO/tao/CSD_ThreadPool/CSD_TP_Task.cpp index 010e0ed9132..5ce745c230e 100644 --- a/TAO/tao/CSD_ThreadPool/CSD_TP_Task.cpp +++ b/TAO/tao/CSD_ThreadPool/CSD_TP_Task.cpp @@ -228,9 +228,6 @@ TAO::CSD::TP_Task::svc() // handle falls out of scope and its destructor performs the // _remove_ref() call on the underlying TP_Request object. } - - // This will never get executed. - return 0; } diff --git a/TAO/tao/CodecFactory/CDR_Encaps_Codec.cpp b/TAO/tao/CodecFactory/CDR_Encaps_Codec.cpp index 4ccaf78f25a..55505a44a48 100644 --- a/TAO/tao/CodecFactory/CDR_Encaps_Codec.cpp +++ b/TAO/tao/CodecFactory/CDR_Encaps_Codec.cpp @@ -194,9 +194,12 @@ TAO_CDR_Encaps_Codec::encode_value (const CORBA::Any & data if (impl->encoded ()) { - TAO::Unknown_IDL_Type *unk = + TAO::Unknown_IDL_Type * const unk = dynamic_cast<TAO::Unknown_IDL_Type *> (impl); + if (!unk) + ACE_THROW_RETURN (CORBA::INTERNAL (), 0); + // We don't want unk's rd_ptr to move, in case we are shared by // another Any, so we use this to copy the state, not the buffer. TAO_InputCDR for_reading (unk->_tao_get_cdr ()); diff --git a/TAO/tao/CodecFactory/CodecFactory.cpp b/TAO/tao/CodecFactory/CodecFactory.cpp index e9ce1b47003..c754673335f 100644 --- a/TAO/tao/CodecFactory/CodecFactory.cpp +++ b/TAO/tao/CodecFactory/CodecFactory.cpp @@ -27,7 +27,7 @@ TAO_CodecFactory_Loader::create_object ( ACE_TCHAR *[] ) { - CORBA::Object_ptr obj = CORBA::Object::_nil (); + CORBA::Object_ptr obj = CORBA::Object_ptr (); ACE_NEW_RETURN (obj, TAO_CodecFactory (orb->orb_core ()), CORBA::Object::_nil ()); diff --git a/TAO/tao/DynamicAny/DynArray_i.cpp b/TAO/tao/DynamicAny/DynArray_i.cpp index fe92067d92c..4f31292d381 100644 --- a/TAO/tao/DynamicAny/DynArray_i.cpp +++ b/TAO/tao/DynamicAny/DynArray_i.cpp @@ -62,9 +62,12 @@ TAO_DynArray_i::init (const CORBA::Any & any) if (impl->encoded ()) { - TAO::Unknown_IDL_Type *unk = + TAO::Unknown_IDL_Type * const unk = dynamic_cast<TAO::Unknown_IDL_Type *> (impl); + if (!unk) + ACE_THROW (CORBA::INTERNAL ()); + cdr = unk->_tao_get_cdr (); } else @@ -345,9 +348,12 @@ TAO_DynArray_i::from_any (const CORBA::Any& any) if (impl->encoded ()) { - TAO::Unknown_IDL_Type *unk = + TAO::Unknown_IDL_Type * const unk = dynamic_cast<TAO::Unknown_IDL_Type *> (impl); + if (!unk) + ACE_THROW (CORBA::INTERNAL ()); + cdr = unk->_tao_get_cdr (); } else @@ -420,9 +426,12 @@ TAO_DynArray_i::to_any (void) if (field_impl->encoded ()) { - TAO::Unknown_IDL_Type *field_unk = + TAO::Unknown_IDL_Type * const field_unk = dynamic_cast<TAO::Unknown_IDL_Type *> (field_impl); + if (!field_unk) + ACE_THROW (CORBA::INTERNAL ()); + field_cdr = field_unk->_tao_get_cdr (); } else diff --git a/TAO/tao/DynamicAny/DynEnum_i.cpp b/TAO/tao/DynamicAny/DynEnum_i.cpp index 0650f58ead1..a5d18951740 100644 --- a/TAO/tao/DynamicAny/DynEnum_i.cpp +++ b/TAO/tao/DynamicAny/DynEnum_i.cpp @@ -51,9 +51,12 @@ TAO_DynEnum_i::init (const CORBA::Any &any) if (impl->encoded ()) { - TAO::Unknown_IDL_Type *unk = + TAO::Unknown_IDL_Type * const unk = dynamic_cast<TAO::Unknown_IDL_Type *> (impl); + if (!unk) + ACE_THROW (CORBA::INTERNAL ()); + // We don't want unk's rd_ptr to move, in case we are shared by // another Any, so we use this to copy the state, not the buffer. TAO_InputCDR for_reading (unk->_tao_get_cdr ()); @@ -174,9 +177,12 @@ TAO_DynEnum_i::from_any (const CORBA::Any& any) if (impl->encoded ()) { - TAO::Unknown_IDL_Type *unk = + TAO::Unknown_IDL_Type * const unk = dynamic_cast<TAO::Unknown_IDL_Type *> (impl); + if (!unk) + ACE_THROW (CORBA::INTERNAL ()); + // We don't want unk's rd_ptr to move, in case we are shared by // another Any, so we use this to copy the state, not the buffer. TAO_InputCDR for_reading (unk->_tao_get_cdr ()); @@ -238,9 +244,12 @@ TAO_DynEnum_i::equal (DynamicAny::DynAny_ptr rhs) if (impl->encoded ()) { - TAO::Unknown_IDL_Type *unk = + TAO::Unknown_IDL_Type * const unk = dynamic_cast<TAO::Unknown_IDL_Type *> (impl); + if (!unk) + ACE_THROW (CORBA::INTERNAL ()); + // We don't want unk's rd_ptr to move, in case we are shared by // another Any, so we use this to copy the state, not the buffer. TAO_InputCDR for_reading (unk->_tao_get_cdr ()); diff --git a/TAO/tao/DynamicAny/DynSequence_i.cpp b/TAO/tao/DynamicAny/DynSequence_i.cpp index c2e5b7be2c3..53e3ba58133 100644 --- a/TAO/tao/DynamicAny/DynSequence_i.cpp +++ b/TAO/tao/DynamicAny/DynSequence_i.cpp @@ -57,7 +57,11 @@ TAO_DynSequence_i::init (const CORBA::Any& any) if (impl->encoded ()) { - TAO::Unknown_IDL_Type *unk = dynamic_cast<TAO::Unknown_IDL_Type *> (impl); + TAO::Unknown_IDL_Type * const unk = + dynamic_cast<TAO::Unknown_IDL_Type *> (impl); + + if (!unk) + ACE_THROW (CORBA::INTERNAL ()); cdr = unk->_tao_get_cdr (); } @@ -478,9 +482,12 @@ TAO_DynSequence_i::from_any (const CORBA::Any & any) if (impl->encoded ()) { - TAO::Unknown_IDL_Type *unk = + TAO::Unknown_IDL_Type * const unk = dynamic_cast<TAO::Unknown_IDL_Type *> (impl); + if (!unk) + ACE_THROW (CORBA::INTERNAL ()); + cdr = unk->_tao_get_cdr (); } else @@ -579,9 +586,12 @@ TAO_DynSequence_i::to_any (void) if (field_impl->encoded ()) { - TAO::Unknown_IDL_Type *field_unk = + TAO::Unknown_IDL_Type * const field_unk = dynamic_cast<TAO::Unknown_IDL_Type *> (field_impl); + if (!field_unk) + ACE_THROW_RETURN (CORBA::INTERNAL (), 0); + field_cdr = field_unk->_tao_get_cdr (); } else diff --git a/TAO/tao/DynamicAny/DynStruct_i.cpp b/TAO/tao/DynamicAny/DynStruct_i.cpp index b93b6a78cbf..416609d53d4 100644 --- a/TAO/tao/DynamicAny/DynStruct_i.cpp +++ b/TAO/tao/DynamicAny/DynStruct_i.cpp @@ -90,6 +90,9 @@ TAO_DynStruct_i::set_from_any (const CORBA::Any & any) { unk = dynamic_cast<TAO::Unknown_IDL_Type *> (impl); + if (!unk) + ACE_THROW (CORBA::INTERNAL ()); + in = unk->_tao_get_cdr (); } else @@ -473,6 +476,9 @@ TAO_DynStruct_i::from_any (const CORBA::Any & any) { unk = dynamic_cast<TAO::Unknown_IDL_Type *> (impl); + if (!unk) + ACE_THROW (CORBA::INTERNAL ()); + in = unk->_tao_get_cdr (); } else @@ -572,6 +578,9 @@ TAO_DynStruct_i::to_any (void) field_unk = dynamic_cast<TAO::Unknown_IDL_Type *> (field_impl); + if (!field_unk) + ACE_THROW_RETURN (CORBA::INTERNAL (), 0); + field_in_cdr = field_unk->_tao_get_cdr (); } else diff --git a/TAO/tao/DynamicAny/DynUnion_i.cpp b/TAO/tao/DynamicAny/DynUnion_i.cpp index e85534a5b5b..562f09784e4 100644 --- a/TAO/tao/DynamicAny/DynUnion_i.cpp +++ b/TAO/tao/DynamicAny/DynUnion_i.cpp @@ -159,9 +159,12 @@ TAO_DynUnion_i::set_from_any (const CORBA::Any & any) if (impl->encoded ()) { - TAO::Unknown_IDL_Type *tmp = + TAO::Unknown_IDL_Type * const tmp = dynamic_cast<TAO::Unknown_IDL_Type *> (impl); + if (!tmp) + ACE_THROW (CORBA::INTERNAL ()); + in = tmp->_tao_get_cdr (); } else @@ -698,9 +701,12 @@ TAO_DynUnion_i::to_any (void) if (disc_any_impl->encoded ()) { - TAO::Unknown_IDL_Type *disc_unk = + TAO::Unknown_IDL_Type * const disc_unk = dynamic_cast<TAO::Unknown_IDL_Type *> (disc_any_impl); + if (!disc_unk) + ACE_THROW_RETURN (CORBA::INTERNAL (), 0); + disc_in_cdr = disc_unk->_tao_get_cdr (); } else @@ -730,9 +736,12 @@ TAO_DynUnion_i::to_any (void) if (member_any_impl->encoded ()) { - TAO::Unknown_IDL_Type *member_unk = + TAO::Unknown_IDL_Type * const member_unk = dynamic_cast<TAO::Unknown_IDL_Type *> (member_any_impl); + if (!member_unk) + ACE_THROW_RETURN (CORBA::INTERNAL (), 0); + member_in_cdr = member_unk->_tao_get_cdr (); } else @@ -991,9 +1000,12 @@ TAO_DynUnion_i::label_match (const CORBA::Any &my_any, if (my_impl->encoded ()) { - TAO::Unknown_IDL_Type *my_unk = + TAO::Unknown_IDL_Type * const my_unk = dynamic_cast<TAO::Unknown_IDL_Type *> (my_impl); + if (!my_unk) + ACE_THROW_RETURN (CORBA::INTERNAL (), false); + // We don't want unk's rd_ptr to move, in case we are shared by // another Any, so we use this to copy the state, not the buffer. TAO_InputCDR for_reading (my_unk->_tao_get_cdr ()); @@ -1011,9 +1023,12 @@ TAO_DynUnion_i::label_match (const CORBA::Any &my_any, if (other_impl->encoded ()) { - TAO::Unknown_IDL_Type *other_unk = + TAO::Unknown_IDL_Type * const other_unk = dynamic_cast<TAO::Unknown_IDL_Type *> (other_impl); + if (!other_unk) + ACE_THROW_RETURN (CORBA::INTERNAL (), false); + // We don't want unk's rd_ptr to move, in case we are shared by // another Any, so we use this to copy the state, not the buffer. TAO_InputCDR for_reading (other_unk->_tao_get_cdr ()); diff --git a/TAO/tao/DynamicInterface/DII_Invocation.cpp b/TAO/tao/DynamicInterface/DII_Invocation.cpp index ff82a8fce72..1c24576d764 100644 --- a/TAO/tao/DynamicInterface/DII_Invocation.cpp +++ b/TAO/tao/DynamicInterface/DII_Invocation.cpp @@ -51,21 +51,26 @@ namespace TAO Dynamic::ParameterList * DII_Invocation::arguments (void) { - // Generate the argument list on demand. - Dynamic::ParameterList *parameter_list = - TAO_RequestInfo_Util::make_parameter_list (); + Dynamic::ParameterList_var safe_parameter_list; - Dynamic::ParameterList_var safe_parameter_list = parameter_list; - - TAO::Argument **args = this->details_.args (); + TAO::Argument ** const args = this->details_.args (); if (this->details_.args_num () > 1) { // Take the second argument since the first is a return value. - TAO::NVList_Argument *tmp_arg = + TAO::NVList_Argument * const tmp_arg = dynamic_cast <TAO::NVList_Argument*> (args[1]); - tmp_arg->interceptor_paramlist (parameter_list); + if (tmp_arg) + { + // Generate the argument list on demand. + Dynamic::ParameterList * const parameter_list = + TAO_RequestInfo_Util::make_parameter_list (); + + safe_parameter_list = parameter_list; + + tmp_arg->interceptor_paramlist (parameter_list); + } } return safe_parameter_list._retn (); @@ -173,21 +178,26 @@ namespace TAO Dynamic::ParameterList * DII_Deferred_Invocation::arguments (void) { - // Generate the argument list on demand. - Dynamic::ParameterList *parameter_list = - TAO_RequestInfo_Util::make_parameter_list (); + Dynamic::ParameterList_var safe_parameter_list; - Dynamic::ParameterList_var safe_parameter_list = parameter_list; - - TAO::Argument **args = this->details_.args (); + TAO::Argument ** const args = this->details_.args (); if (this->details_.args_num () > 1) { // Take the second argument since the first is a return value. - TAO::NVList_Argument *tmp_arg = + TAO::NVList_Argument * const tmp_arg = dynamic_cast <TAO::NVList_Argument*> (args[1]); - tmp_arg->interceptor_paramlist (parameter_list); + if (tmp_arg) + { + // Generate the argument list on demand. + Dynamic::ParameterList * const parameter_list = + TAO_RequestInfo_Util::make_parameter_list (); + + safe_parameter_list = parameter_list; + + tmp_arg->interceptor_paramlist (parameter_list); + } } return safe_parameter_list._retn (); diff --git a/TAO/tao/DynamicInterface/Dynamic_Implementation.cpp b/TAO/tao/DynamicInterface/Dynamic_Implementation.cpp index e37d9cac8d3..33c6a895e69 100644 --- a/TAO/tao/DynamicInterface/Dynamic_Implementation.cpp +++ b/TAO/tao/DynamicInterface/Dynamic_Implementation.cpp @@ -36,7 +36,7 @@ TAO_DynamicImplementation::_this (void) TAO_Stub *stub = this->_create_stub (); // Create a object. - CORBA::Object_ptr retval = CORBA::Object::_nil (); + CORBA::Object_ptr retval = CORBA::Object_ptr (); ACE_NEW_RETURN (retval, CORBA::Object (stub, 1, diff --git a/TAO/tao/EndpointPolicy/EndpointPolicy_Factory.cpp b/TAO/tao/EndpointPolicy/EndpointPolicy_Factory.cpp index b0d51bbd0f6..4174b4b2202 100644 --- a/TAO/tao/EndpointPolicy/EndpointPolicy_Factory.cpp +++ b/TAO/tao/EndpointPolicy/EndpointPolicy_Factory.cpp @@ -22,7 +22,7 @@ TAO_BEGIN_VERSIONED_NAMESPACE_DECL TAO_EndpointPolicy_Factory::TAO_EndpointPolicy_Factory (TAO_ORB_Core * orb_core) -: orb_core_ (orb_core) + : orb_core_ (orb_core) { } @@ -33,52 +33,57 @@ TAO_EndpointPolicy_Factory::create_policy ( const CORBA::Any &value) { if (type == EndpointPolicy::ENDPOINT_POLICY_TYPE) - { - const EndpointPolicy::EndpointList* endpoint_list; - if ((value >>= endpoint_list) == 0) - throw ::CORBA::PolicyError (CORBA::BAD_POLICY_VALUE); - - TAO_Acceptor_Registry & registry - = this->orb_core_->lane_resources ().acceptor_registry (); - - TAO_Acceptor ** acceptors_begin = registry.begin (); - TAO_Acceptor ** acceptors_end = registry.end (); - CORBA::ULong num_eps = endpoint_list->length (); + { + const EndpointPolicy::EndpointList* endpoint_list; + if (!(value >>= endpoint_list)) + throw ::CORBA::PolicyError (CORBA::BAD_POLICY_VALUE); - // The endpoint list in the value is validated to ensure that - // at least one endpoint in the list matches an endpoint the - // ORB is listening on. + TAO_Acceptor_Registry & registry = + this->orb_core_->lane_resources ().acceptor_registry (); - bool found_one = false; - for (CORBA::ULong idx = 0; !found_one && idx < num_eps; ++idx) - { - CORBA::ULong prot_tag = (*endpoint_list)[idx]->protocol_tag(); + TAO_Acceptor ** const acceptors_begin = registry.begin (); + TAO_Acceptor ** const acceptors_end = registry.end (); + CORBA::ULong const num_eps = endpoint_list->length (); - const TAO_Endpoint_Value_Impl *evi = - dynamic_cast <const TAO_Endpoint_Value_Impl*> ((*endpoint_list)[idx]); + // The endpoint list in the value is validated to ensure that + // at least one endpoint in the list matches an endpoint the + // ORB is listening on. - for (TAO_Acceptor** acceptor = acceptors_begin; - !found_one && acceptor != acceptors_end; - ++acceptor) + bool found_one = false; + for (CORBA::ULong idx = 0; !found_one && idx < num_eps; ++idx) { - if ((*acceptor)->tag() == prot_tag) - found_one = evi->validate_acceptor(*acceptor); + CORBA::ULong prot_tag = (*endpoint_list)[idx]->protocol_tag(); + + TAO_Endpoint_Value_Impl const * const evi = + dynamic_cast <TAO_Endpoint_Value_Impl const *> ( + (*endpoint_list)[idx].in ()); + + if (!evi) + continue; + + for (TAO_Acceptor** acceptor = acceptors_begin; + !found_one && acceptor != acceptors_end; + ++acceptor) + { + if ((*acceptor)->tag () == prot_tag) + found_one = evi->validate_acceptor (*acceptor); + } } + + // There is no endpoint policy value matches an endpoint the ORB + // is listening on. A CORBA::PolicyError exception with a + // PolicyErrorCode of UNSUPPORTED_POLICY_VALUE is raised. + if (!found_one) + throw ::CORBA::PolicyError (CORBA::UNSUPPORTED_POLICY_VALUE); + + TAO_EndpointPolicy_i *tmp = 0; + ACE_NEW_THROW_EX (tmp, + TAO_EndpointPolicy_i (*endpoint_list), + CORBA::NO_MEMORY (TAO::VMCID, + CORBA::COMPLETED_NO)); + + return tmp; } - // There is no endpoint policy value matches an endpoint the ORB - // is listening on. A CORBA::PolicyError exception with a - // PolicyErrorCode of UNSUPPORTED_POLICY_VALUE is raised. - if (!found_one) - throw ::CORBA::PolicyError (CORBA::UNSUPPORTED_POLICY_VALUE); - - TAO_EndpointPolicy_i *tmp = 0; - ACE_NEW_THROW_EX (tmp, - TAO_EndpointPolicy_i (*endpoint_list), - CORBA::NO_MEMORY (TAO::VMCID, - CORBA::COMPLETED_NO)); - - return tmp; - } else throw ::CORBA::PolicyError (CORBA::BAD_POLICY_TYPE); } diff --git a/TAO/tao/EndpointPolicy/EndpointPolicy_ORBInitializer.cpp b/TAO/tao/EndpointPolicy/EndpointPolicy_ORBInitializer.cpp index ea00901c563..9c8da8144ca 100644 --- a/TAO/tao/EndpointPolicy/EndpointPolicy_ORBInitializer.cpp +++ b/TAO/tao/EndpointPolicy/EndpointPolicy_ORBInitializer.cpp @@ -35,6 +35,10 @@ TAO_EndpointPolicy_ORBInitializer::register_policy_factories ( ) { TAO_ORBInitInfo * local_info = dynamic_cast <TAO_ORBInitInfo *> (info); + + if (!local_info) + ACE_THROW (CORBA::INTERNAL ()); + TAO_ORB_Core * the_orb_core = local_info->orb_core (); // Register the EndpointPolicy policy factories. diff --git a/TAO/tao/Exception.h b/TAO/tao/Exception.h index 1153255ea71..3662bb298d5 100644 --- a/TAO/tao/Exception.h +++ b/TAO/tao/Exception.h @@ -105,9 +105,6 @@ namespace CORBA /// Destructor. virtual ~Exception (void); - /// Copy constructor. - Exception (const Exception &src); - // = To throw the exception (when using the standard mapping). virtual void _raise (void) const = 0; @@ -181,6 +178,9 @@ namespace CORBA /// Default constructor. Exception (void); + /// Copy constructor. + Exception (const Exception &src); + /// Assignment operator. Exception & operator = (const Exception & src); diff --git a/TAO/tao/IIOP_Acceptor.cpp b/TAO/tao/IIOP_Acceptor.cpp index 722e511e226..6a3800ebba2 100644 --- a/TAO/tao/IIOP_Acceptor.cpp +++ b/TAO/tao/IIOP_Acceptor.cpp @@ -677,7 +677,7 @@ TAO_IIOP_Acceptor::parse_address (const char *address, { // In this case we have to find the end of the numeric address and // start looking for the port separator from there. - const char *cp_pos = ACE_OS::strchr(address, ']'); + char const * const cp_pos = ACE_OS::strchr (address, ']'); if (cp_pos == 0) { // No valid IPv6 address specified. @@ -689,6 +689,12 @@ TAO_IIOP_Acceptor::parse_address (const char *address, } else { + // Extract out just the host part of the address. + size_t const len = cp_pos - (address + 1); + + if (len >= sizeof (tmp_host)) + return -1; + ipv6_in_host = true; host_defaulted = (cp_pos == address+1) || (cp_pos == address+3 && address[1] == ':' && address[2] == ':'); @@ -698,8 +704,7 @@ TAO_IIOP_Acceptor::parse_address (const char *address, port_separator_loc = 0; if (def_type) *def_type = AF_INET6; - // Extract out just the host part of the address. - size_t const len = cp_pos - (address + 1); + ACE_OS::memcpy (tmp_host, address + 1, len); tmp_host[len] = '\0'; } @@ -712,6 +717,10 @@ TAO_IIOP_Acceptor::parse_address (const char *address, { // Extract out just the host part of the address. size_t const len = port_separator_loc - address; + + if (len >= sizeof (tmp_host)) + return -1; + ACE_OS::memcpy (tmp_host, address, len); tmp_host[len] = '\0'; } @@ -762,7 +771,11 @@ TAO_IIOP_Acceptor::parse_address (const char *address, if (tmp_host[0] == '\0') { // Extract out just the host part of the address. - const size_t len = port_separator_loc - address; + size_t const len = port_separator_loc - address; + + if (len >= sizeof (tmp_host)) + return -1; + ACE_OS::memcpy (tmp_host, address, len); tmp_host[len] = '\0'; } diff --git a/TAO/tao/IIOP_Connector.cpp b/TAO/tao/IIOP_Connector.cpp index 1af0fb429cf..77d80f5cc9b 100644 --- a/TAO/tao/IIOP_Connector.cpp +++ b/TAO/tao/IIOP_Connector.cpp @@ -215,28 +215,34 @@ TAO_IIOP_Connector::make_connection (TAO::Profile_Transport_Resolver *r, TAO_IIOP_Connection_Handler **sh_ptr = &svc_handler; TAO_IIOP_Endpoint **ep_ptr = &iiop_endpoint; TAO_LF_Multi_Event mev; - mev.add_event(svc_handler); - TAO_Transport* tp = this->complete_connection (result, desc, - sh_ptr, ep_ptr, - 1U, r, &mev, timeout); - return tp; + mev.add_event (svc_handler); + + return this->complete_connection (result, + desc, + sh_ptr, + ep_ptr, + 1U, + r, + &mev, + timeout); } TAO_Transport * -TAO_IIOP_Connector::make_parallel_connection (TAO::Profile_Transport_Resolver *r, - TAO_Transport_Descriptor_Interface &desc, - ACE_Time_Value *timeout) +TAO_IIOP_Connector::make_parallel_connection ( + TAO::Profile_Transport_Resolver * r, + TAO_Transport_Descriptor_Interface & desc, + ACE_Time_Value * timeout) { TAO_Endpoint *root_ep = desc.endpoint(); unsigned max_count = 1; unsigned long ns_stagger = - this->orb_core()->orb_params()->parallel_connect_delay(); + this->orb_core ()->orb_params ()->parallel_connect_delay (); unsigned long sec_stagger = ns_stagger/1000; ns_stagger = (ns_stagger % 1000) * 1000000; - for (TAO_Endpoint *ep = root_ep->next_filtered (this->orb_core(),0); + for (TAO_Endpoint *ep = root_ep->next_filtered (this->orb_core(), 0); ep != 0; - ep = ep->next_filtered(this->orb_core(),root_ep)) - max_count++; + ep = ep->next_filtered (this->orb_core(), root_ep)) + ++max_count; if (TAO_debug_level > 2) ACE_DEBUG ((LM_DEBUG, @@ -296,8 +302,14 @@ TAO_IIOP_Connector::make_parallel_connection (TAO::Profile_Transport_Resolver *r TAO_Transport *winner = 0; if (count > 0) // only complete if at least one pending or success - winner = this->complete_connection (result,desc, - shlist,eplist,count,r,&mev,timeout); + winner = this->complete_connection (result, + desc, + shlist, + eplist, + count,r, + &mev, + timeout); + delete [] shlist; // reference reductions should have been done already delete [] eplist; return winner; @@ -493,7 +505,7 @@ TAO_IIOP_Connector::complete_connection (int result, for (unsigned i = 0; i < count; i++) { ACE_ERROR ((LM_ERROR, - ACE_TEXT ("(%P|%t) IIOP_Connector::make_connection,") + ACE_TEXT ("(%P|%t) IIOP_Connector::complete_connection,") ACE_TEXT (" connection to <%s:%d> failed (%p)\n"), ACE_TEXT_CHAR_TO_TCHAR (ep_list[i]->host ()), ep_list[i]->port (), diff --git a/TAO/tao/IORTable/Table_Adapter.cpp b/TAO/tao/IORTable/Table_Adapter.cpp index 5d836646df0..eac61635d6d 100644 --- a/TAO/tao/IORTable/Table_Adapter.cpp +++ b/TAO/tao/IORTable/Table_Adapter.cpp @@ -94,7 +94,7 @@ TAO_Table_Adapter::check_close (int) int TAO_Table_Adapter::priority (void) const { - return 16; // @@ + return static_cast<int> (TAO_DEFAULT_ADAPTER_REGISTRY_SIZE); } int diff --git a/TAO/tao/MCAST_Parser.cpp b/TAO/tao/MCAST_Parser.cpp index 88f391ba04b..f93709b0786 100644 --- a/TAO/tao/MCAST_Parser.cpp +++ b/TAO/tao/MCAST_Parser.cpp @@ -39,7 +39,7 @@ TAO_MCAST_Parser::match_prefix (const char *ior_string) const CORBA::Object_ptr TAO_MCAST_Parser::parse_string (const char *ior, CORBA::ORB_ptr orb) { - const char *mcast_name = + char const * const mcast_name = ior + sizeof (::mcast_prefix) + 1; assign_to_variables (mcast_name); @@ -48,40 +48,30 @@ TAO_MCAST_Parser::parse_string (const char *ior, CORBA::ORB_ptr orb) * Now that we got the global variables. * we can invoke multicast_to_service and multicast_query */ - CORBA::Object_ptr object = CORBA::Object::_nil (); - - CORBA::UShort const port = - (CORBA::UShort) ACE_OS::atoi (this->mcast_port_.in ()); - ACE_Time_Value *timeout = orb->get_timeout (); - object = multicast_to_service (service_name_.in (), - port, - this->mcast_address_.in (), - this->mcast_ttl_.in (), - this->mcast_nic_.in (), - orb, - timeout); - - return object; + return + this->multicast_to_service (service_name_.in (), + this->mcast_port_, + this->mcast_address_.in (), + this->mcast_ttl_, + this->mcast_nic_.in (), + orb, + timeout + ACE_ENV_ARG_PARAMETER); } CORBA::Object_ptr TAO_MCAST_Parser::multicast_to_service (const char *service_name, - u_short port, + unsigned short port, const char *mcast_address, - const char *mcast_ttl, + int mcast_ttl, const char *mcast_nic, CORBA::ORB_ptr orb, ACE_Time_Value *timeout) { - char buf[2048]; - char *ior = buf; - - CORBA::String_var cleaner; - - CORBA::Object_var return_value = - CORBA::Object::_nil (); + char buf[TAO_DEFAULT_IOR_SIZE]; + char * ior = buf; // Use UDP multicast to locate the service. int const result = this->multicast_query (ior, @@ -93,13 +83,16 @@ TAO_MCAST_Parser::multicast_to_service (const char *service_name, timeout, orb); - // If the IOR didn't fit into <buf>, memory for it was dynamically - // allocated - make sure it gets deallocated. - if (ior != buf) - cleaner = ior; + CORBA::Object_var return_value; if (result == 0) { + CORBA::String_var cleaner; + // If the IOR didn't fit into <buf>, memory for it was dynamically + // allocated - make sure it gets deallocated. + if (ior != buf) + cleaner = ior; + // Convert IOR to an object reference. return_value = orb->string_to_object (ior); @@ -110,11 +103,11 @@ TAO_MCAST_Parser::multicast_to_service (const char *service_name, } int -TAO_MCAST_Parser::multicast_query (char *&buf, +TAO_MCAST_Parser::multicast_query (char* & buf, const char *service_name, - u_short port, + unsigned short port, const char *mcast_address, - const char *mcast_ttl, + int mcast_ttl, const char *mcast_nic, ACE_Time_Value *timeout, CORBA::ORB_ptr orb) @@ -185,7 +178,7 @@ TAO_MCAST_Parser::multicast_query (char *&buf, multicast_addr.get_type ()); // Set TTL - int mcast_ttl_optval = ACE_OS::atoi (mcast_ttl); + int mcast_ttl_optval = mcast_ttl; #if defined (ACE_HAS_IPV6) if (multicast_addr.get_type () == AF_INET6) @@ -293,7 +286,7 @@ TAO_MCAST_Parser::multicast_query (char *&buf, // Allocate more space for the ior if we don't // have enough. ior_len = (CORBA::Short) ACE_NTOHS (ior_len); - if (ior_len > TAO_DEFAULT_IOR_SIZE) + if (ior_len >= TAO_DEFAULT_IOR_SIZE) { buf = CORBA::string_alloc (ior_len); if (buf == 0) @@ -352,14 +345,16 @@ TAO_MCAST_Parser::multicast_query (char *&buf, } void -TAO_MCAST_Parser::assign_to_variables (const char * &mcast_name) +TAO_MCAST_Parser::assign_to_variables (char const * mcast_name) { /* * The format now is "multicast_address:port:nicaddress:ttl/object_key" */ ACE_CString mcast_name_cstring (mcast_name); - ssize_t pos_colon1 = mcast_name_cstring.find (':', 0); + ACE_CString::size_type pos_colon1 = + mcast_name_cstring.find (':', 0); + #if defined (ACE_HAS_IPV6) // IPv6 numeric address in host string? bool ipv6_in_host = false; @@ -370,7 +365,8 @@ TAO_MCAST_Parser::assign_to_variables (const char * &mcast_name) { // In this case we have to find the end of the numeric address and // start looking for the port separator from there. - int cp_pos = mcast_name_cstring.find (']', 0); + ACE_CString::size_type const cp_pos = + mcast_name_cstring.find (']', 0); if (cp_pos == 0) { // No valid IPv6 address specified. @@ -397,9 +393,9 @@ TAO_MCAST_Parser::assign_to_variables (const char * &mcast_name) if (pos_colon1 == 0) { #if defined (ACE_HAS_IPV6) - const char *default_addr = ACE_DEFAULT_MULTICASTV6_ADDR; + const char default_addr[] = ACE_DEFAULT_MULTICASTV6_ADDR; #else /* ACE_HAS_IPV6 */ - const char *default_addr = ACE_DEFAULT_MULTICAST_ADDR; + const char default_addr[] = ACE_DEFAULT_MULTICAST_ADDR; #endif /* !ACE_HAS_IPV6 */ this->mcast_address_ = default_addr; } @@ -421,45 +417,37 @@ TAO_MCAST_Parser::assign_to_variables (const char * &mcast_name) mcast_name_cstring.length() - pos_colon1); - ssize_t pos_colon2 = mcast_name_cstring.find (':', 0); + ACE_CString::size_type const pos_colon2 = + mcast_name_cstring.find (':', 0); if (pos_colon2 == 0) { - /* - * If the port is not specified, use the default. - * The default multicast port is the same as the default port - * no. for Naming_Service, for now. But for other services, - * check and modify the default values as needed. - */ - char default_port[33]; - - int trial_port = TAO_DEFAULT_NAME_SERVER_REQUEST_PORT; - if (mcast_name_cstring.find ("InterfaceRepository") != ACE_CString::npos) { - trial_port = TAO_DEFAULT_INTERFACEREPO_SERVER_REQUEST_PORT; + this->mcast_port_ = + TAO_DEFAULT_INTERFACEREPO_SERVER_REQUEST_PORT; } else if (mcast_name_cstring.find ("ImplRepoService") != ACE_CString::npos) { - trial_port = TAO_DEFAULT_IMPLREPO_SERVER_REQUEST_PORT; + this->mcast_port_ = + TAO_DEFAULT_IMPLREPO_SERVER_REQUEST_PORT; } else if (mcast_name_cstring.find ("TradingService") != ACE_CString::npos) { - trial_port = TAO_DEFAULT_TRADING_SERVER_REQUEST_PORT; + this->mcast_port_ = TAO_DEFAULT_TRADING_SERVER_REQUEST_PORT; } - - - ACE_OS::itoa (trial_port, default_port, 10); - - this->mcast_port_ = (const char *) default_port; } else { - this->mcast_port_ = mcast_name_cstring.substring (0, - pos_colon2).c_str (); + int const the_port = + ACE_OS::atoi (mcast_name_cstring.substring (0, + pos_colon2).c_str ()); + + if (the_port > 0 && the_port < 0xffffL) + this->mcast_port_ = the_port; } mcast_name_cstring = @@ -467,7 +455,7 @@ TAO_MCAST_Parser::assign_to_variables (const char * &mcast_name) mcast_name_cstring.length() - pos_colon2); - ssize_t pos_colon3 = mcast_name_cstring.find (':', 0); + ACE_CString::size_type const pos_colon3 = mcast_name_cstring.find (':', 0); this->mcast_nic_ = mcast_name_cstring.substring (0, @@ -477,28 +465,26 @@ TAO_MCAST_Parser::assign_to_variables (const char * &mcast_name) mcast_name_cstring.substring (pos_colon3 + 1, mcast_name_cstring.length() - pos_colon3); - ssize_t pos_colon4 = mcast_name_cstring.find ('/', 0); + ACE_CString::size_type const pos_colon4 = + mcast_name_cstring.find ('/', 0); - if (pos_colon4 == 0) + if (pos_colon4 != 0) { - // And, the default TTL to be 1 - const char *default_ttl = "1"; - this->mcast_ttl_ = default_ttl; - } - else - { - this->mcast_ttl_ = - mcast_name_cstring.substring (0, - pos_colon4).c_str (); + // Change TTL to non-default value. + int const the_ttl = + ACE_OS::atoi (mcast_name_cstring.substring (0, pos_colon4).c_str ()); + + if (the_ttl > 0 && the_ttl <= 255) // Valid TTLs: (0, 255] + this->mcast_ttl_ = the_ttl; } + mcast_name_cstring = mcast_name_cstring.substring (pos_colon4, mcast_name_cstring.length() - pos_colon4); this->service_name_ = mcast_name_cstring.substring (1, - mcast_name_cstring.length() - -1).c_str (); + mcast_name_cstring.length() - 1).c_str (); } TAO_END_VERSIONED_NAMESPACE_DECL diff --git a/TAO/tao/MCAST_Parser.h b/TAO/tao/MCAST_Parser.h index 1065838e85a..d3d8f5b2fc1 100644 --- a/TAO/tao/MCAST_Parser.h +++ b/TAO/tao/MCAST_Parser.h @@ -56,32 +56,42 @@ public: private: CORBA::Object_ptr multicast_to_service (const char *service_name, - CORBA::UShort port, + unsigned short port, const char *mcast_address, - const char *mcast_ttl, + int mcast_ttl, const char *mcast_nic, CORBA::ORB_ptr orb, ACE_Time_Value *timeout); int multicast_query (char *&buf, const char *service_name, - u_short port, + unsigned short port, const char *mcast_address, - const char *mcast_ttl, + int mcast_ttl, const char *mcast_nic, ACE_Time_Value *timeout, CORBA::ORB_ptr orb); /* Simple method to assign values to the global members: mcast_address_, mcast_port_, mcast_nic_, mcast_ttl_ */ - void assign_to_variables (const char * &mcast_name_ptr); + void assign_to_variables (char const * mcast_name_ptr); + +private: - // Global private variables CORBA::String_var mcast_address_; - CORBA::String_var mcast_port_; + + /// Default multicast port (currently Name Service mcast port). + unsigned short mcast_port_; + + /// Multicast network interface card. CORBA::String_var mcast_nic_; - CORBA::String_var mcast_ttl_; + + /// Default time-to-live (default is 1). + int mcast_ttl_; + + /// Multicast service name CORBA::String_var service_name_; + }; TAO_END_VERSIONED_NAMESPACE_DECL diff --git a/TAO/tao/MCAST_Parser.inl b/TAO/tao/MCAST_Parser.inl index fc19f658c44..afa7790eb1a 100644 --- a/TAO/tao/MCAST_Parser.inl +++ b/TAO/tao/MCAST_Parser.inl @@ -2,10 +2,17 @@ // // $Id$ +#include "tao/default_ports.h" + TAO_BEGIN_VERSIONED_NAMESPACE_DECL ACE_INLINE TAO_MCAST_Parser::TAO_MCAST_Parser (void) + : mcast_address_ () + , mcast_port_ (TAO_DEFAULT_NAME_SERVER_REQUEST_PORT) + , mcast_nic_ () + , mcast_ttl_ (1) + , service_name_ () { } diff --git a/TAO/tao/ObjRefTemplate/ObjectReferenceTemplate_i.cpp b/TAO/tao/ObjRefTemplate/ObjectReferenceTemplate_i.cpp index 622bb1a0eb5..78b973c67fb 100644 --- a/TAO/tao/ObjRefTemplate/ObjectReferenceTemplate_i.cpp +++ b/TAO/tao/ObjRefTemplate/ObjectReferenceTemplate_i.cpp @@ -63,10 +63,14 @@ namespace TAO const PortableInterceptor::ObjectId & ) { - if (CORBA::is_nil(poa_.in())) + if (CORBA::is_nil (this->poa_.in ())) throw ::CORBA::BAD_INV_ORDER (); - TAO_Root_POA* tao_poa = dynamic_cast<TAO_Root_POA*>(poa_.in()); + TAO_Root_POA* const tao_poa = + dynamic_cast<TAO_Root_POA*> (this->poa_.in()); + + if (!tao_poa) + throw ::CORBA::INTERNAL (); return tao_poa->invoke_key_to_object (); } diff --git a/TAO/tao/Object_KeyC.cpp b/TAO/tao/Object_KeyC.cpp index abd6d5ded9a..af8f7841018 100644 --- a/TAO/tao/Object_KeyC.cpp +++ b/TAO/tao/Object_KeyC.cpp @@ -38,6 +38,7 @@ #endif /* __BORLANDC__ */ #include "ace/ACE.h" +#include "ace/Truncate.h" #include "ace/OS_NS_string.h" #include "ace/os_include/os_ctype.h" @@ -97,8 +98,8 @@ TAO::ObjectKey::~ObjectKey (void) // Hand crafted. void -TAO::ObjectKey::encode_sequence_to_string (char * &str, - const TAO::unbounded_value_sequence<CORBA::Octet> &seq) +TAO::ObjectKey::encode_sequence_to_string (char* & str, + TAO::unbounded_value_sequence<CORBA::Octet> const & seq) { // We must allocate a buffer which is (gag) 3 times the length // of the sequence, which is the length required in the worst-case @@ -109,19 +110,22 @@ TAO::ObjectKey::encode_sequence_to_string (char * &str, // OR, we could just return this space. The classic time-space tradeoff, // and for now we'll let time win out, which means that we only do the // allocation once. - u_int len = 3 * seq.length (); /* space for zero termination not needed */; + CORBA::ULong const seq_len = seq.length (); + CORBA::ULong const len = 3 * seq_len; /* space for zero termination + not needed */ str = CORBA::string_alloc (len); - char *cp = str; + char * const eos = str + len; + char * cp = str; - for (u_int i = 0; - cp < (str + len) && i < seq.length(); + for (CORBA::ULong i = 0; + cp < eos && i < seq_len; ++i) { - u_char bt = seq[i]; + unsigned char bt = seq[i]; if (is_legal (bt)) { - *cp++ = (char) bt; + *cp++ = static_cast<char> (bt); continue; } @@ -133,11 +137,12 @@ TAO::ObjectKey::encode_sequence_to_string (char * &str, *cp = '\0'; } -int TAO::ObjectKey::is_legal (u_char & c) +CORBA::Boolean +TAO::ObjectKey::is_legal (unsigned char c) { - if (isalnum(c)) + if (isalnum (c)) { - return 1; + return true; } else { @@ -150,8 +155,9 @@ int TAO::ObjectKey::is_legal (u_char & c) } void -TAO::ObjectKey::decode_string_to_sequence (TAO::unbounded_value_sequence<CORBA::Octet> &seq, - const char *str) +TAO::ObjectKey::decode_string_to_sequence ( + TAO::unbounded_value_sequence<CORBA::Octet> & seq, + char const * str) { if (str == 0) { @@ -159,18 +165,24 @@ TAO::ObjectKey::decode_string_to_sequence (TAO::unbounded_value_sequence<CORBA:: return; } - size_t length = ACE_OS::strlen (str); - const char *eos = str + length; - const char *cp = str; + size_t const str_len = ACE_OS::strlen (str); - // Set the length of the sequence to be as long as - // we'll possibly need...we'll reset it to the actual - // length later. - seq.length (length); + // Ensure sequence length value does not exceed maximum value for + // sequence index type (CORBA::ULong). This is mostly an issue for + // 64-bit MS Windows builds. + CORBA::ULong const len = + ACE_Utils::truncate_cast<CORBA::ULong> (str_len); + + char const * const eos = str + str_len; + char const * cp = str; - u_int i = 0; + // Set the length of the sequence to be as long as we'll possibly + // need...we'll reset it to the actual length later. + seq.length (len); + + CORBA::ULong i = 0; for (; - cp < eos && i < seq.length (); + cp < eos && i < len; ++i) { if (*cp == '%' || *cp == '\\') @@ -178,8 +190,8 @@ TAO::ObjectKey::decode_string_to_sequence (TAO::unbounded_value_sequence<CORBA:: // This is an escaped non-printable, // so we decode the hex values into // the sequence's octet - seq[i] = (u_char) (ACE::hex2byte (cp[1]) << 4); - seq[i] |= (u_char) ACE::hex2byte (cp[2]); + seq[i] = static_cast<CORBA::Octet> (ACE::hex2byte (cp[1]) << 4); + seq[i] |= static_cast<CORBA::Octet> (ACE::hex2byte (cp[2])); cp += 3; } else diff --git a/TAO/tao/Object_KeyC.h b/TAO/tao/Object_KeyC.h index e21fd58e7d6..a28f547aaa4 100644 --- a/TAO/tao/Object_KeyC.h +++ b/TAO/tao/Object_KeyC.h @@ -120,21 +120,21 @@ namespace TAO // Hand crafted. static void encode_sequence_to_string ( - char * &str, - const TAO::unbounded_value_sequence<CORBA::Octet> &seq + char* & str, + TAO::unbounded_value_sequence<CORBA::Octet> const & seq ); static void decode_string_to_sequence ( TAO::unbounded_value_sequence<CORBA::Octet> &seq, - const char *str + char const * str ); - static int is_legal (u_char & c); + static CORBA::Boolean is_legal (unsigned char c); /// A special method that gives no regard to how the ORB has /// configured the resource factory. This will be used only /// during Profile decoding and should be safe. This is a solution - /// for the bug report [BUG 1616] - static CORBA::Boolean demarshal_key (ObjectKey &key, - TAO_InputCDR &cdr); + /// for the bug report [Bug 1616] + static CORBA::Boolean demarshal_key (ObjectKey & key, + TAO_InputCDR & cdr); }; #endif /* end #if !defined */ diff --git a/TAO/tao/PI/PICurrent_Loader.cpp b/TAO/tao/PI/PICurrent_Loader.cpp index e75f088da48..c563f30d03f 100644 --- a/TAO/tao/PI/PICurrent_Loader.cpp +++ b/TAO/tao/PI/PICurrent_Loader.cpp @@ -30,7 +30,7 @@ TAO_BEGIN_VERSIONED_NAMESPACE_DECL CORBA::Object_ptr TAO_PICurrent_Loader::create_object (CORBA::ORB_ptr orb, int, ACE_TCHAR *[]) { - CORBA::Object_ptr obj = CORBA::Object::_nil (); + CORBA::Object_ptr obj = CORBA::Object_ptr (); ACE_NEW_RETURN (obj, TAO::PICurrent (*orb->orb_core ()), CORBA::Object::_nil ()); diff --git a/TAO/tao/Policy_Set.cpp b/TAO/tao/Policy_Set.cpp index 9ef040f04b3..a8f8db0e797 100644 --- a/TAO/tao/Policy_Set.cpp +++ b/TAO/tao/Policy_Set.cpp @@ -60,11 +60,14 @@ TAO_Policy_Set::TAO_Policy_Set (const TAO_Policy_Set &rhs) CORBA::Policy_var copy = policy->copy (); + TAO_Cached_Policy_Type const cached_type = + copy->_tao_cached_type (); + // Add the "cacheable" policies into the cache. - if (copy->_tao_cached_type () != TAO_CACHED_POLICY_UNCACHED) + if (cached_type != TAO_CACHED_POLICY_UNCACHED + && cached_type >= 0) { - this->cached_policies_[copy->_tao_cached_type ()] = - copy.ptr (); + this->cached_policies_[cached_type] = copy.ptr (); } this->policy_list_[i] = copy._retn (); @@ -111,10 +114,14 @@ TAO_Policy_Set::copy_from (TAO_Policy_Set *source) CORBA::ULong const length = this->policy_list_.length (); this->policy_list_.length (length + 1); + TAO_Cached_Policy_Type const cached_type = + copy->_tao_cached_type (); + // Add the "cacheable" policies into the cache. - if (copy->_tao_cached_type () != TAO_CACHED_POLICY_UNCACHED) + if (cached_type != TAO_CACHED_POLICY_UNCACHED + && cached_type >= 0) { - this->cached_policies_[copy->_tao_cached_type ()] = copy.ptr (); + this->cached_policies_[cached_type] = copy.ptr (); } this->policy_list_[length] = copy._retn (); @@ -235,9 +242,11 @@ TAO_Policy_Set::set_policy (const CORBA::Policy_ptr policy) // If this is a policy that gets accessed on the critical path, // save a pointer to it in the cache. - TAO_Cached_Policy_Type cached_policy_type = policy->_tao_cached_type (); + TAO_Cached_Policy_Type const cached_policy_type = + policy->_tao_cached_type (); - if (cached_policy_type != TAO_CACHED_POLICY_UNCACHED) + if (cached_policy_type != TAO_CACHED_POLICY_UNCACHED + && cached_policy_type >= 0) { this->cached_policies_[cached_policy_type] = copy.ptr (); } diff --git a/TAO/tao/PortableServer/ServantRetentionStrategyFactoryImpl.cpp b/TAO/tao/PortableServer/ServantRetentionStrategyFactoryImpl.cpp index 7cc94f9f523..72da99cd4aa 100644 --- a/TAO/tao/PortableServer/ServantRetentionStrategyFactoryImpl.cpp +++ b/TAO/tao/PortableServer/ServantRetentionStrategyFactoryImpl.cpp @@ -2,6 +2,7 @@ #include "tao/PortableServer/ServantRetentionStrategyFactoryImpl.h" #include "tao/PortableServer/ServantRetentionStrategy.h" +#include "tao/debug.h" #include "ace/Dynamic_Service.h" #include "ace/Log_Msg.h" @@ -40,9 +41,14 @@ namespace TAO ACE_Dynamic_Service<ServantRetentionStrategyFactory>::instance (strategy_factory_name); if (strategy_factory == 0) - ACE_ERROR ((LM_ERROR, - ACE_TEXT ("(%P|%t) ERROR, Unable to get %s\n"), - strategy_factory_name)); + { + if (TAO_debug_level > 1) + ACE_ERROR ((LM_ERROR, + ACE_TEXT ("(%P|%t) ERROR, Unable to get %s\n"), + strategy_factory_name)); + + return 0; + } return strategy_factory->create (value); } diff --git a/TAO/tao/Queued_Message.h b/TAO/tao/Queued_Message.h index c8e8883fd11..22f24e04f6f 100644 --- a/TAO/tao/Queued_Message.h +++ b/TAO/tao/Queued_Message.h @@ -17,7 +17,6 @@ #include "tao/LF_Invocation_Event.h" #include "ace/os_include/os_stddef.h" -#include "ace/Time_Value.h" #if !defined (ACE_LACKS_PRAGMA_ONCE) # pragma once @@ -28,6 +27,7 @@ struct iovec; ACE_BEGIN_VERSIONED_NAMESPACE_DECL class ACE_Message_Block; class ACE_Allocator; +class ACE_Time_Value; ACE_END_VERSIONED_NAMESPACE_DECL TAO_BEGIN_VERSIONED_NAMESPACE_DECL diff --git a/TAO/tao/RTCORBA/RT_Endpoint_Utils.cpp b/TAO/tao/RTCORBA/RT_Endpoint_Utils.cpp index 1cb9458734c..94904eeb443 100644 --- a/TAO/tao/RTCORBA/RT_Endpoint_Utils.cpp +++ b/TAO/tao/RTCORBA/RT_Endpoint_Utils.cpp @@ -24,7 +24,11 @@ TAO_RT_Endpoint_Utils::policy (TAO_Cached_Policy_Type type, { CORBA::Policy *policy = CORBA::Policy::_nil (); - TAO_RT_Stub *rt_stub = dynamic_cast<TAO_RT_Stub *> (r.stub ()); + TAO_RT_Stub * const rt_stub = + dynamic_cast<TAO_RT_Stub *> (r.stub ()); + + if (!rt_stub) + throw CORBA::INTERNAL (); try { diff --git a/TAO/tao/RTCORBA/RT_Invocation_Endpoint_Selectors.cpp b/TAO/tao/RTCORBA/RT_Invocation_Endpoint_Selectors.cpp index fd526d1325c..896172a49f9 100644 --- a/TAO/tao/RTCORBA/RT_Invocation_Endpoint_Selectors.cpp +++ b/TAO/tao/RTCORBA/RT_Invocation_Endpoint_Selectors.cpp @@ -149,6 +149,9 @@ TAO_RT_Invocation_Endpoint_Selector::endpoint_from_profile ( // Narrow to the RT Stub. TAO_RT_Stub *rt_stub = dynamic_cast <TAO_RT_Stub *> (r.stub ()); + if (!rt_stub) + throw CORBA::INTERNAL (); + // Get the priority model policy. CORBA::Policy_var priority_model_policy = rt_stub->get_cached_policy (TAO_CACHED_POLICY_PRIORITY_MODEL); diff --git a/TAO/tao/RTCORBA/RT_ORB.cpp b/TAO/tao/RTCORBA/RT_ORB.cpp index 51c6cf40e1d..eae181f202b 100644 --- a/TAO/tao/RTCORBA/RT_ORB.cpp +++ b/TAO/tao/RTCORBA/RT_ORB.cpp @@ -33,6 +33,9 @@ TAO_RT_ORB::TAO_RT_ORB (TAO_ORB_Core *orb_core, TAO_RT_Thread_Lane_Resources_Manager *rt_thread_lane_resources_manager = dynamic_cast <TAO_RT_Thread_Lane_Resources_Manager *> (thread_lane_resources_manager); + if (!rt_thread_lane_resources_manager) + throw CORBA::INTERNAL (); + this->tp_manager_ = &rt_thread_lane_resources_manager->tp_manager (); } diff --git a/TAO/tao/RTCORBA/RT_PolicyFactory.cpp b/TAO/tao/RTCORBA/RT_PolicyFactory.cpp index 91fc5db1537..5257e6eaa82 100644 --- a/TAO/tao/RTCORBA/RT_PolicyFactory.cpp +++ b/TAO/tao/RTCORBA/RT_PolicyFactory.cpp @@ -42,7 +42,7 @@ TAO_RT_PolicyFactory::create_policy ( CORBA::Policy_ptr TAO_RT_PolicyFactory::_create_policy (CORBA::PolicyType type) { - CORBA::Policy_ptr policy = CORBA::Policy::_nil (); + CORBA::Policy_ptr policy = CORBA::Policy_ptr (); if (type == RTCORBA::PRIORITY_MODEL_POLICY_TYPE) { diff --git a/TAO/tao/RTCORBA/RT_Protocols_Hooks.cpp b/TAO/tao/RTCORBA/RT_Protocols_Hooks.cpp index a030baa940a..383b3da11b9 100644 --- a/TAO/tao/RTCORBA/RT_Protocols_Hooks.cpp +++ b/TAO/tao/RTCORBA/RT_Protocols_Hooks.cpp @@ -472,6 +472,9 @@ TAO_RT_Protocols_Hooks::rt_service_context ( TAO_RT_Stub *rt_stub = dynamic_cast<TAO_RT_Stub *> (stub); + if (!rt_stub) + throw CORBA::INTERNAL (); + CORBA::Policy_var priority_model_policy = rt_stub->get_cached_policy (TAO_CACHED_POLICY_PRIORITY_MODEL); diff --git a/TAO/tao/RTCORBA/RT_Transport_Descriptor.cpp b/TAO/tao/RTCORBA/RT_Transport_Descriptor.cpp index 79c86d3d785..886314dd2f0 100644 --- a/TAO/tao/RTCORBA/RT_Transport_Descriptor.cpp +++ b/TAO/tao/RTCORBA/RT_Transport_Descriptor.cpp @@ -63,7 +63,7 @@ TAO_RT_Transport_Descriptor::duplicate (void) // Note that we cannot use <insert> because that will reverse the stack. if (new_descriptor->property_list_ == 0) new_descriptor->property_list_ = new_property; - else + else if (current_new_property != 0) current_new_property->next_ = new_property; current_new_property = new_property; diff --git a/TAO/tao/RTPortableServer/RT_Policy_Validator.cpp b/TAO/tao/RTPortableServer/RT_Policy_Validator.cpp index 0925a40adbd..1c13f110363 100644 --- a/TAO/tao/RTPortableServer/RT_Policy_Validator.cpp +++ b/TAO/tao/RTPortableServer/RT_Policy_Validator.cpp @@ -537,11 +537,17 @@ TAO_POA_RT_Policy_Validator::extract_thread_pool (TAO_ORB_Core &orb_core, RTCORBA::RTORB_var rt_orb = RTCORBA::RTORB::_narrow (object.in ()); - TAO_RT_ORB *tao_rt_orb = dynamic_cast <TAO_RT_ORB *> (rt_orb.in ()); + TAO_RT_ORB * const tao_rt_orb = + dynamic_cast <TAO_RT_ORB *> (rt_orb.in ()); - TAO_Thread_Pool_Manager &tp_manager = tao_rt_orb->tp_manager (); + if (!tao_rt_orb) + ACE_THROW_RETURN (CORBA::INTERNAL (), + 0); - TAO_Thread_Pool *thread_pool = tp_manager.get_threadpool (thread_pool_id); + TAO_Thread_Pool_Manager & tp_manager = tao_rt_orb->tp_manager (); + + TAO_Thread_Pool * const thread_pool = + tp_manager.get_threadpool (thread_pool_id); if (thread_pool == 0) throw PortableServer::POA::InvalidPolicy (); diff --git a/TAO/tao/SystemException.h b/TAO/tao/SystemException.h index d0057eb1186..0c9121c7f0a 100644 --- a/TAO/tao/SystemException.h +++ b/TAO/tao/SystemException.h @@ -83,9 +83,6 @@ namespace CORBA { public: - /// Copy constructor. - SystemException (const SystemException & src); - /// Destructor. virtual ~SystemException (void); @@ -138,6 +135,9 @@ namespace CORBA /// Default constructor. SystemException (void); + /// Copy constructor. + SystemException (const SystemException & src); + /// Assignment operator. SystemException & operator= (const SystemException &src); diff --git a/TAO/tao/TAO_Internal.cpp b/TAO/tao/TAO_Internal.cpp index e65ae318cca..29b7b224564 100644 --- a/TAO/tao/TAO_Internal.cpp +++ b/TAO/tao/TAO_Internal.cpp @@ -293,15 +293,15 @@ TAO::ORB::open_services (ACE_Service_Gestalt* pcfg, // Be certain to copy the program name so that service configurator // has something to skip! - ACE_CString argv0 (""); + ACE_CString gargv0 (""); if (argc > 0 && argv != 0) { - argv0 = ACE_TEXT_ALWAYS_CHAR (argv[0]); + gargv0 = ACE_TEXT_ALWAYS_CHAR (argv[0]); } global_svc_config_argv.length (1); - global_svc_config_argv[0] = argv0.c_str (); + global_svc_config_argv[0] = gargv0.c_str (); if (parse_global_args_i (argc, argv, global_svc_config_argv, true) == -1) { diff --git a/TAO/tao/TypeCodeFactory/TypeCodeFactory_i.cpp b/TAO/tao/TypeCodeFactory/TypeCodeFactory_i.cpp index 217ef0965a5..9be99e5798f 100644 --- a/TAO/tao/TypeCodeFactory/TypeCodeFactory_i.cpp +++ b/TAO/tao/TypeCodeFactory/TypeCodeFactory_i.cpp @@ -143,7 +143,7 @@ TAO_TypeCodeFactory_i::create_union_tc ( CORBA::TypeCode_ptr discriminator_type, const CORBA::UnionMemberSeq &members) { - CORBA::TypeCode_ptr tc = CORBA::TypeCode::_nil (); + CORBA::TypeCode_ptr tc = CORBA::TypeCode_ptr (); if (name == 0 || !this->valid_name (name)) { @@ -363,6 +363,10 @@ TAO_TypeCodeFactory_i::create_union_tc ( TAO::Unknown_IDL_Type * const unk = dynamic_cast<TAO::Unknown_IDL_Type *> (impl); + if (!unk) + ACE_THROW_RETURN (CORBA::INTERNAL (), + CORBA::TypeCode::_nil ()); + // We don't want unk's rd_ptr to move, in case we // are shared by another Any, so we use this to // copy the state, not the buffer. @@ -584,7 +588,11 @@ TAO_TypeCodeFactory_i::create_union_tc ( recursive_typecode_type * const rtc = dynamic_cast<recursive_typecode_type *> (recursive_tc.in ()); - ACE_ASSERT (rtc); + if (!rtc) + { + ACE_THROW_RETURN (CORBA::INTERNAL (), + tc); + } rtc->union_parameters (name, duped_disc_type, @@ -613,7 +621,7 @@ TAO_TypeCodeFactory_i::create_enum_tc ( const char *name, const CORBA::EnumMemberSeq &members) { - CORBA::TypeCode_ptr tc = CORBA::TypeCode::_nil (); + CORBA::TypeCode_ptr tc = CORBA::TypeCode_ptr (); if (name == 0 || !this->valid_name (name)) { @@ -787,7 +795,7 @@ TAO_TypeCodeFactory_i::create_native_tc ( CORBA::TypeCode_ptr TAO_TypeCodeFactory_i::create_recursive_tc (const char *id) { - CORBA::TypeCode_ptr tc = CORBA::TypeCode::_nil (); + CORBA::TypeCode_ptr tc = CORBA::TypeCode_ptr (); if (id == 0 || !this->valid_id (id)) { @@ -992,6 +1000,9 @@ TAO_TypeCodeFactory_i::compute_default_label ( TAO::Unknown_IDL_Type *unk = dynamic_cast<TAO::Unknown_IDL_Type *> (impl); + if (!unk) + throw CORBA::INTERNAL (); + // We don't want unk's rd_ptr to move, in case // we are shared by another Any, so we use this // to copy the state, not the buffer. @@ -1172,7 +1183,7 @@ TAO_TypeCodeFactory_i::sequence_array_tc_common ( ) { - CORBA::TypeCode_ptr tc = CORBA::TypeCode::_nil (); + CORBA::TypeCode_ptr tc = CORBA::TypeCode_ptr (); CORBA::Boolean const valid_element = this->valid_content_type (element_type @@ -1204,7 +1215,7 @@ TAO_TypeCodeFactory_i::struct_except_tc_common ( ) { - CORBA::TypeCode_ptr tc = CORBA::TypeCode::_nil (); + CORBA::TypeCode_ptr tc = CORBA::TypeCode_ptr (); if (name == 0 || !this->valid_name (name)) { @@ -1284,7 +1295,11 @@ TAO_TypeCodeFactory_i::struct_except_tc_common ( recursive_typecode_type * const rtc = dynamic_cast<recursive_typecode_type *> (recursive_tc.in ()); - ACE_ASSERT (rtc); + if (!rtc) + { + ACE_THROW_RETURN (CORBA::INTERNAL (), + tc); + } rtc->struct_parameters (name, fields, len); @@ -1310,7 +1325,7 @@ TAO_TypeCodeFactory_i::alias_value_box_tc_common ( CORBA::TCKind kind ) { - CORBA::TypeCode_ptr tc = CORBA::TypeCode::_nil (); + CORBA::TypeCode_ptr tc = CORBA::TypeCode_ptr (); if (name == 0 || !this->valid_name (name)) { @@ -1354,7 +1369,7 @@ TAO_TypeCodeFactory_i::value_event_tc_common ( ) { - CORBA::TypeCode_ptr tc = CORBA::TypeCode::_nil (); + CORBA::TypeCode_ptr tc = CORBA::TypeCode_ptr (); if (name == 0 || !this->valid_name (name)) { @@ -1438,7 +1453,11 @@ TAO_TypeCodeFactory_i::value_event_tc_common ( recursive_typecode_type * const rtc = dynamic_cast<recursive_typecode_type *> (recursive_tc.in ()); - ACE_ASSERT (rtc); + if (!rtc) + { + ACE_THROW_RETURN (CORBA::INTERNAL (), + tc); + } rtc->valuetype_parameters (name, type_modifier, @@ -1662,6 +1681,10 @@ TAO_TypeCodeFactory_i::unique_label_values ( TAO::Unknown_IDL_Type *unk = dynamic_cast<TAO::Unknown_IDL_Type *> (impl); + if (!unk) + ACE_THROW_RETURN (CORBA::INTERNAL (), + false); + // We don't want unk's rd_ptr to move, in case // we are shared by another Any, so we use this // to copy the state, not the buffer. @@ -1768,7 +1791,11 @@ TAO_TypeCodeFactory_i::check_recursion (CORBA::TCKind kind, TAO::TypeCodeFactory::Recursive_TypeCode *> ( member_tc.in ()); - ACE_ASSERT (rtc); + if (!rtc) + { + ACE_THROW_RETURN (CORBA::INTERNAL (), + false); + } if (CORBA::is_nil (recursive_tc)) { @@ -1837,7 +1864,11 @@ TAO_TypeCodeFactory_i::check_recursion (CORBA::TCKind kind, dynamic_cast<TAO::TypeCodeFactory::Recursive_TypeCode *> (content_tc.in ()); - ACE_ASSERT (rtc); + if (!rtc) + { + ACE_THROW_RETURN (CORBA::INTERNAL (), + false); + } if (CORBA::is_nil (recursive_tc)) { @@ -1873,7 +1904,7 @@ TAO_TypeCodeFactory_i::check_recursion (CORBA::TCKind kind, CORBA::TypeCode_ptr TAO_TypeCodeFactory_i::make_recursive_tc (CORBA::TCKind kind, char const * id) { - CORBA::TypeCode_ptr tc = CORBA::TypeCode::_nil (); + CORBA::TypeCode_ptr tc = CORBA::TypeCode_ptr (); switch (kind) { diff --git a/TAO/tao/diffs/Object_Key.diff b/TAO/tao/diffs/Object_Key.diff index bb632ec4c49..53e071d8cd5 100644 --- a/TAO/tao/diffs/Object_Key.diff +++ b/TAO/tao/diffs/Object_Key.diff @@ -5,13 +5,14 @@ #endif /* __BORLANDC__ */ +#include "ace/ACE.h" ++#include "ace/Numeric_Limits.h" +#include "ace/OS_NS_string.h" +#include "ace/os_include/os_ctype.h" + // TAO_IDL - Generated from // be\be_visitor_arg_traits.cpp:69 -@@ -88,6 +92,150 @@ +@@ -88,2 +95,2 @@ TAO::ObjectKey::~ObjectKey (void) {} @@ -30,19 +31,19 @@ + // OR, we could just return this space. The classic time-space tradeoff, + // and for now we'll let time win out, which means that we only do the + // allocation once. -+ u_int len = 3 * seq.length (); /* space for zero termination not needed */; ++ unsigned int const len = 3 * seq.length (); /* space for zero termination not needed */; + str = CORBA::string_alloc (len); + + char *cp = str; + -+ for (u_int i = 0; ++ for (unsigned int i = 0; + cp < (str + len) && i < seq.length(); + ++i) + { -+ u_char bt = seq[i]; ++ unsigned char bt = seq[i]; + if (is_legal (bt)) + { -+ *cp++ = (char) bt; ++ *cp++ = static_cast<char> (bt); + continue; + } + @@ -54,11 +55,12 @@ + *cp = '\0'; +} + -+int TAO::ObjectKey::is_legal (u_char & c) ++CORBA::Boolean ++TAO::ObjectKey::is_legal (unsigned char c) +{ + if (isalnum(c)) + { -+ return 1; ++ return true; + } + else + { @@ -80,18 +82,28 @@ + return; + } + -+ u_int length = ACE_OS::strlen (str); -+ const char *eos = str + length; -+ const char *cp = str; ++ size_t const str_len = ACE_OS::strlen (str); ++ ++ // Ensure sequence length value does not exceed maximum value for ++ // sequence index type (CORBA::ULong). This is mostly an issue for ++ // 64-bit MS Windows builds. ++ CORBA::ULong const len = ++ (sizeof (str_len) > sizeof (CORBA::ULong) // both unsigned ++ && str_len > ACE_Numeric_Limits<CORBA::ULong>::max () ++ ? ACE_Numeric_Limits<CORBA::ULong>::max () ++ : static_cast<CORBA::ULong> (str_len)); ++ ++ char const * const eos = str + len; ++ char const * cp = str; + + // Set the length of the sequence to be as long as + // we'll possibly need...we'll reset it to the actual + // length later. -+ seq.length (length); ++ seq.length (len); + -+ u_int i = 0; ++ CORBA::ULong i = 0; + for (; -+ cp < eos && i < seq.length (); ++ cp < eos && i < len; + ++i) + { + if (*cp == '%' || *cp == '\\') @@ -99,8 +111,8 @@ + // This is an escaped non-printable, + // so we decode the hex values into + // the sequence's octet -+ seq[i] = (u_char) (ACE::hex2byte (cp[1]) << 4); -+ seq[i] |= (u_char) ACE::hex2byte (cp[2]); ++ seq[i] = static_cast<CORBA::Octet> (ACE::hex2byte (cp[1]) << 4); ++ seq[i] |= static_cast<CORBA::Octet> (ACE::hex2byte (cp[2])); + cp += 3; + } + else @@ -162,7 +174,7 @@ // TAO_IDL - Generated from --- orig/Object_KeyC.h 2005-04-08 10:17:40.978604800 +0200 +++ Object_KeyC.h 2005-04-08 10:17:41.879900800 +0200 -@@ -117,6 +117,25 @@ +@@ -117,4 +117,23 @@ ) : TAO_Unbounded_Sequence<CORBA::Octet> (length, mb) {} #endif /* TAO_NO_COPY_OCTET_SEQUENCE == 1 */ @@ -177,7 +189,7 @@ + TAO::unbounded_value_sequence<CORBA::Octet> &seq, + const char *str + ); -+ static int is_legal (u_char & c); ++ static CORBA::Boolean is_legal (unsigned char c); + + /// A special method that gives no regard to how the ORB has + /// configured the resource factory. This will be used only diff --git a/TAO/tao/orbconf.h b/TAO/tao/orbconf.h index e56dd169168..c4439ba74e9 100644 --- a/TAO/tao/orbconf.h +++ b/TAO/tao/orbconf.h @@ -92,6 +92,11 @@ TAO_BEGIN_VERSIONED_NAMESPACE_DECL const size_t TAO_DEFAULT_ORB_TABLE_SIZE = 16; #endif /* !TAO_DEFAULT_ORB_TABLE_SIZE */ +// The default size of TAO's adapter registry. +#if !defined (TAO_DEFAULT_ADAPTER_REGISTRY_SIZE) +const size_t TAO_DEFAULT_ADAPTER_REGISTRY_SIZE = 16; +#endif /* !TAO_DEFAULT_ORB_TABLE_SIZE */ + // The default size of the reply dispatcher table, ie. if the reply // dispatcher strategy needs a table to maintain association between // request id's and reply dispatchers |