From 5defc9d62f9445c28befa001d10929a741cfb256 Mon Sep 17 00:00:00 2001 From: Johnny Willemsen Date: Thu, 9 Mar 2023 08:05:30 +0100 Subject: [PATCH 1/3] Check the skel_args pointer before using it, when it is nullptr we should throw an exception, shouldn't happen as this is called from generated code * tao/x11/portable_server/get_skel_arg.h: --- tao/x11/portable_server/get_skel_arg.h | 61 +++++++++++++++++--------- 1 file changed, 40 insertions(+), 21 deletions(-) diff --git a/tao/x11/portable_server/get_skel_arg.h b/tao/x11/portable_server/get_skel_arg.h index 958ffa75..bf299388 100644 --- a/tao/x11/portable_server/get_skel_arg.h +++ b/tao/x11/portable_server/get_skel_arg.h @@ -25,16 +25,21 @@ namespace TAOX11_NAMESPACE get_ret_arg (TAO_Operation_Details const * details, TAO::Argument * const * skel_args) { - if (details != 0 && details->use_stub_args ()) + if (details != nullptr && details->use_stub_args ()) { - return static_cast::ret_val *> ( - details->args ()[0])->arg (); + return static_cast::ret_val *> (details->args ()[0])->arg (); } else { - return static_cast::ret_val *> ( - skel_args[0])->arg (); + if (skel_args) + { + return static_cast::ret_val *> (skel_args[0])->arg (); + } + else + { + throw TAOX11_NAMESPACE::CORBA::INTERNAL (); + } } } @@ -45,15 +50,20 @@ namespace TAOX11_NAMESPACE TAO_TAO::Argument * const * skel_args, size_t i) { - if (details != 0 && details->use_stub_args ()) + if (details != nullptr && details->use_stub_args ()) { - return static_cast::in_arg_val *> ( - details->args ()[i])->arg (); + return static_cast::in_arg_val *> (details->args ()[i])->arg (); } else { - return static_cast::in_arg_val *> ( - skel_args[i])->arg (); + if (skel_args) + { + return static_cast::in_arg_val *> (skel_args[i])->arg (); + } + else + { + throw TAOX11_NAMESPACE::CORBA::INTERNAL (); + } } } @@ -64,16 +74,20 @@ namespace TAOX11_NAMESPACE TAO::Argument * const * skel_args, size_t i) { - if (details != 0 && details->use_stub_args ()) + if (details != nullptr && details->use_stub_args ()) { - return static_cast::inout_arg_val *> ( - details->args ()[i])->arg (); + return static_cast::inout_arg_val *> (details->args ()[i])->arg (); } else { - return static_cast::inout_arg_val *> ( - skel_args[i])->arg (); - + if (skel_args) + { + return static_cast::inout_arg_val *> (skel_args[i])->arg (); + } + else + { + throw TAOX11_NAMESPACE::CORBA::INTERNAL (); + } } } @@ -84,15 +98,20 @@ namespace TAOX11_NAMESPACE TAO::Argument * const * skel_args, size_t i) { - if (details != 0 && details->use_stub_args ()) + if (details != nullptr && details->use_stub_args ()) { - return static_cast::out_arg_val *> ( - details->args ()[i])->arg (); + return static_cast::out_arg_val *> (details->args ()[i])->arg (); } else { - return static_cast::out_arg_val *> ( - skel_args[i])->arg (); + if (skel_args) + { + return static_cast::out_arg_val *> (skel_args[i])->arg (); + } + else + { + throw TAOX11_NAMESPACE::CORBA::INTERNAL (); + } } } } // namespace PS From 239c6d535cd25bff6af3ff0804cc53ef0568592a Mon Sep 17 00:00:00 2001 From: Johnny Willemsen Date: Thu, 9 Mar 2023 08:06:30 +0100 Subject: [PATCH 2/3] Simplified pointer comparisons * tao/x11/portable_server/get_skel_arg.h: --- tao/x11/portable_server/get_skel_arg.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/tao/x11/portable_server/get_skel_arg.h b/tao/x11/portable_server/get_skel_arg.h index bf299388..7c02c649 100644 --- a/tao/x11/portable_server/get_skel_arg.h +++ b/tao/x11/portable_server/get_skel_arg.h @@ -25,7 +25,7 @@ namespace TAOX11_NAMESPACE get_ret_arg (TAO_Operation_Details const * details, TAO::Argument * const * skel_args) { - if (details != nullptr && details->use_stub_args ()) + if (details && details->use_stub_args ()) { return static_cast::ret_val *> (details->args ()[0])->arg (); @@ -50,7 +50,7 @@ namespace TAOX11_NAMESPACE TAO_TAO::Argument * const * skel_args, size_t i) { - if (details != nullptr && details->use_stub_args ()) + if (details && details->use_stub_args ()) { return static_cast::in_arg_val *> (details->args ()[i])->arg (); } @@ -74,7 +74,7 @@ namespace TAOX11_NAMESPACE TAO::Argument * const * skel_args, size_t i) { - if (details != nullptr && details->use_stub_args ()) + if (details && details->use_stub_args ()) { return static_cast::inout_arg_val *> (details->args ()[i])->arg (); } @@ -98,7 +98,7 @@ namespace TAOX11_NAMESPACE TAO::Argument * const * skel_args, size_t i) { - if (details != nullptr && details->use_stub_args ()) + if (details && details->use_stub_args ()) { return static_cast::out_arg_val *> (details->args ()[i])->arg (); } From 10bccc17d67b282686ab4b09d19fe0bf4872ba73 Mon Sep 17 00:00:00 2001 From: Johnny Willemsen Date: Thu, 9 Mar 2023 11:46:44 +0100 Subject: [PATCH 3/3] As this code is called from the TAO core we should throw a TAO exception * tao/x11/portable_server/get_skel_arg.h: --- tao/x11/portable_server/get_skel_arg.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/tao/x11/portable_server/get_skel_arg.h b/tao/x11/portable_server/get_skel_arg.h index 7c02c649..c1cf9e11 100644 --- a/tao/x11/portable_server/get_skel_arg.h +++ b/tao/x11/portable_server/get_skel_arg.h @@ -38,7 +38,7 @@ namespace TAOX11_NAMESPACE } else { - throw TAOX11_NAMESPACE::CORBA::INTERNAL (); + throw TAO_CORBA::INTERNAL (); } } } @@ -62,7 +62,7 @@ namespace TAOX11_NAMESPACE } else { - throw TAOX11_NAMESPACE::CORBA::INTERNAL (); + throw TAO_CORBA::INTERNAL (); } } } @@ -86,7 +86,7 @@ namespace TAOX11_NAMESPACE } else { - throw TAOX11_NAMESPACE::CORBA::INTERNAL (); + throw TAO_CORBA::INTERNAL (); } } } @@ -110,7 +110,7 @@ namespace TAOX11_NAMESPACE } else { - throw TAOX11_NAMESPACE::CORBA::INTERNAL (); + throw TAO_CORBA::INTERNAL (); } } }