This is an automated email from the ASF dual-hosted git repository.

zwoop pushed a commit to branch 9.0.x
in repository https://gitbox.apache.org/repos/asf/trafficserver.git


The following commit(s) were added to refs/heads/9.0.x by this push:
     new fb7abd5  Change alloca usage to malloc/free
fb7abd5 is described below

commit fb7abd5222ab5c60d973a6f8c925b7963a554abe
Author: Evan Zelkowitz <e...@apache.org>
AuthorDate: Wed Jan 29 14:13:41 2020 -0700

    Change alloca usage to malloc/free
    
    This code is in a while(true) loop, so every time the manager receives a 
message it is expanding the stack more and more, since it never exits traffic 
manager could end up blowing its stack if it receives enough messages.  
Changing to allocate on each message and free when done
    
    Addresses issue #6351
    
    (cherry picked from commit 614bbe0a4efdb121df4da7f83049bdaa628bb1d8)
---
 mgmt/LocalManager.cc | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/mgmt/LocalManager.cc b/mgmt/LocalManager.cc
index 09c9c1c..652ff47 100644
--- a/mgmt/LocalManager.cc
+++ b/mgmt/LocalManager.cc
@@ -406,7 +406,7 @@ LocalManager::pollMgmtProcessServer()
 
         // read the message
         if ((res = mgmt_read_pipe(watched_process_fd, reinterpret_cast<char 
*>(&mh_hdr), sizeof(MgmtMessageHdr))) > 0) {
-          MgmtMessageHdr *mh_full = static_cast<MgmtMessageHdr 
*>(alloca(sizeof(MgmtMessageHdr) + mh_hdr.data_len));
+          MgmtMessageHdr *mh_full = static_cast<MgmtMessageHdr 
*>(malloc(sizeof(MgmtMessageHdr) + mh_hdr.data_len));
           memcpy(mh_full, &mh_hdr, sizeof(MgmtMessageHdr));
           char *data_raw = reinterpret_cast<char *>(mh_full) + 
sizeof(MgmtMessageHdr);
           if ((res = mgmt_read_pipe(watched_process_fd, data_raw, 
mh_hdr.data_len)) > 0) {
@@ -414,6 +414,7 @@ LocalManager::pollMgmtProcessServer()
           } else if (res < 0) {
             mgmt_fatal(0, "[LocalManager::pollMgmtProcessServer] Error in read 
(errno: %d)\n", -res);
           }
+          free(mh_full);
         } else if (res < 0) {
           mgmt_fatal(0, "[LocalManager::pollMgmtProcessServer] Error in read 
(errno: %d)\n", -res);
         }

Reply via email to