summaryrefslogtreecommitdiff
path: root/tests/Process_Strategy_Test.cpp
diff options
context:
space:
mode:
authorlevine <levine@ae88bc3d-4319-0410-8dbf-d08b4c9d3795>1997-04-23 20:53:25 +0000
committerlevine <levine@ae88bc3d-4319-0410-8dbf-d08b4c9d3795>1997-04-23 20:53:25 +0000
commitb4294e6315fc08a0926641227acbe45e84b64eb2 (patch)
treedc5a4a2fa1d7980cab6e43065f92c0713cad8aa7 /tests/Process_Strategy_Test.cpp
parent51b32e7f453719a7192dca24ec81b958a77dfb55 (diff)
downloadATCD-b4294e6315fc08a0926641227acbe45e84b64eb2.tar.gz
(client): null terminate "buf" before call to ACE_OS::strrchr () to avoid uninitialized memory read.
Diffstat (limited to 'tests/Process_Strategy_Test.cpp')
-rw-r--r--tests/Process_Strategy_Test.cpp7
1 files changed, 6 insertions, 1 deletions
diff --git a/tests/Process_Strategy_Test.cpp b/tests/Process_Strategy_Test.cpp
index c022d1bc279..72b5d0967b6 100644
--- a/tests/Process_Strategy_Test.cpp
+++ b/tests/Process_Strategy_Test.cpp
@@ -503,6 +503,7 @@ client (void *arg)
command = "read";
command_len = ACE_OS::strlen (command);
+ int bytes_read = 0;
if (connector.connect (stream, server_addr) == -1)
ACE_ERROR_RETURN ((LM_ERROR, "%p\n", "open"), 0);
@@ -510,10 +511,14 @@ client (void *arg)
&command_len, sizeof command_len,
command, command_len) == -1)
ACE_ERROR_RETURN ((LM_ERROR, "%p\n", "send"), 0);
- else if (stream.recv (buf, sizeof buf) <= 0)
+ else if ((bytes_read = stream.recv (buf, sizeof buf)) <= 0)
ACE_ERROR_RETURN ((LM_ERROR, "%p\n", "recv"), 0);
else
{
+ // Null terminate buf to avoid an uninitialized memory read in the
+ // call to ACE_OS::strrchr ().
+ buf [bytes_read] = '\0';
+
size_t count = ACE_OS::atoi (ACE_OS::strrchr (buf, ' '));
ACE_DEBUG ((LM_DEBUG, "(%P|%t) count = %d\n", count));