summaryrefslogtreecommitdiff
path: root/TAO
diff options
context:
space:
mode:
authorLuke Mewburn <Luke@Mewburn.net>2022-09-02 21:18:26 +1000
committerLuke Mewburn <Luke@Mewburn.net>2022-09-02 21:18:26 +1000
commitc320b8022b5fd32b9237f1211f3f6d29c2192b21 (patch)
tree25c50169bf8d69a8fd99b3ba179c5919685d581e /TAO
parent1c9614d34d09d39486e579c6c21b0218997739c8 (diff)
downloadATCD-c320b8022b5fd32b9237f1211f3f6d29c2192b21.tar.gz
Fix -Wformat-security issues for wchar_t
Use %ls instead of %s when using wchar_t Fixes issue #1906.
Diffstat (limited to 'TAO')
-rw-r--r--TAO/orbsvcs/FTRT_Event_Service/Factory_Service/EventChannelFactory_i.cpp12
-rw-r--r--TAO/orbsvcs/ImplRepo_Service/ImR_Activator_i.cpp12
2 files changed, 18 insertions, 6 deletions
diff --git a/TAO/orbsvcs/FTRT_Event_Service/Factory_Service/EventChannelFactory_i.cpp b/TAO/orbsvcs/FTRT_Event_Service/Factory_Service/EventChannelFactory_i.cpp
index d8898f573e4..79724e745ca 100644
--- a/TAO/orbsvcs/FTRT_Event_Service/Factory_Service/EventChannelFactory_i.cpp
+++ b/TAO/orbsvcs/FTRT_Event_Service/Factory_Service/EventChannelFactory_i.cpp
@@ -100,10 +100,16 @@ CORBA::Object_ptr EventChannelFactory_i::create_process (
}
str = ACE_TEXT_CHAR_TO_TCHAR(process_str);
+#if !defined (ACE_WIN32) && defined (ACE_USES_WCHAR)
+ const ACE_TCHAR *fmt_s = ACE_TEXT ("%ls");
+#else
+ const ACE_TCHAR *fmt_s = ACE_TEXT ("%s");
+#endif
+
const int ENV_BUF_LEN = 512;
ACE_TCHAR buf[ENV_BUF_LEN];
server_addr.addr_to_string(buf,ENV_BUF_LEN,0);
- options.setenv(ACE_TEXT("EventChannelFactoryAddr"), ACE_TEXT("%s"), buf);
+ options.setenv(ACE_TEXT("EventChannelFactoryAddr"), fmt_s, buf);
// extract the object ID from the criteria
for (CORBA::ULong i = 0; i < the_criteria.length(); ++i)
@@ -114,7 +120,7 @@ CORBA::Object_ptr EventChannelFactory_i::create_process (
const char* id_str = name[0].id.in();
the_criteria[i].val >>= val;
if (id_str[0] != '-') // environment variable
- options.setenv(ACE_TEXT_CHAR_TO_TCHAR(id_str), ACE_TEXT("%s"), val);
+ options.setenv(ACE_TEXT_CHAR_TO_TCHAR(id_str), fmt_s, val);
else {// command line option
ACE_OS::sprintf(buf, ACE_TEXT(" %s %s"), id_str, val);
str += buf;
@@ -124,7 +130,7 @@ CORBA::Object_ptr EventChannelFactory_i::create_process (
ORBSVCS_DEBUG((LM_DEBUG, "Command Line : %s\n", str.c_str()));
- options.command_line(ACE_TEXT("%s"), str.c_str());
+ options.command_line(fmt_s, str.c_str());
// Try to create a new process running date.
ACE_Process new_process;
diff --git a/TAO/orbsvcs/ImplRepo_Service/ImR_Activator_i.cpp b/TAO/orbsvcs/ImplRepo_Service/ImR_Activator_i.cpp
index e605c547c89..3b7c728d6d6 100644
--- a/TAO/orbsvcs/ImplRepo_Service/ImR_Activator_i.cpp
+++ b/TAO/orbsvcs/ImplRepo_Service/ImR_Activator_i.cpp
@@ -527,6 +527,12 @@ ImR_Activator_i::start_server(const char* name,
throw ImplementationRepository::CannotActivate(CORBA::string_dup (reason));
}
+#if !defined (ACE_WIN32) && defined (ACE_USES_WCHAR)
+ const ACE_TCHAR *fmt_s = ACE_TEXT ("%ls");
+#else
+ const ACE_TCHAR *fmt_s = ACE_TEXT ("%s");
+#endif
+
size_t const cmdline_buf_len = ACE_OS::strlen(cmdline);
if (debug_ > 0)
ORBSVCS_DEBUG((LM_DEBUG,
@@ -537,7 +543,7 @@ ImR_Activator_i::start_server(const char* name,
1,
cmdline_buf_len + 1,
this->env_buf_len_, this->max_env_vars_);
- proc_opts.command_line (ACE_TEXT("%s"), ACE_TEXT_CHAR_TO_TCHAR(cmdline));
+ proc_opts.command_line (fmt_s, ACE_TEXT_CHAR_TO_TCHAR(cmdline));
proc_opts.working_directory (dir);
// Win32 does not support the CLOSE_ON_EXEC semantics for sockets
// the way unix does, so in order to avoid having the child process
@@ -564,13 +570,13 @@ ImR_Activator_i::start_server(const char* name,
{
CORBA::String_var ior = orb_->object_to_string (locator_.in ());
proc_opts.setenv (ACE_TEXT ("ImplRepoServiceIOR"),
- ACE_TEXT ("%s"), ACE_TEXT_CHAR_TO_TCHAR (ior.in ()));
+ fmt_s, ACE_TEXT_CHAR_TO_TCHAR (ior.in ()));
}
for (CORBA::ULong i = 0; i < env.length (); ++i)
{
proc_opts.setenv (ACE_TEXT_CHAR_TO_TCHAR (env[i].name.in ()),
- ACE_TEXT ("%s"), ACE_TEXT_CHAR_TO_TCHAR (env[i].value.in ()));
+ fmt_s, ACE_TEXT_CHAR_TO_TCHAR (env[i].value.in ()));
}
pid = this->process_mgr_.spawn (proc_opts, this);