Github user jpeach commented on a diff in the pull request: https://github.com/apache/trafficserver/pull/1073#discussion_r84208238 --- Diff: cmd/traffic_manager/traffic_manager.cc --- @@ -611,31 +614,35 @@ main(int argc, const char **argv) /* Update cmd line overrides/environmental overrides/etc */ if (tsArgs) { /* Passed command line args for proxy */ + char* new_proxy_opts = new char[strlen(lmgmt->proxy_options) + strlen(tsArgs) + 1]; + strcpy(new_proxy_opts, lmgmt->proxy_options); + strcat(new_proxy_opts, tsArgs); ats_free(lmgmt->proxy_options); - lmgmt->proxy_options = tsArgs; - mgmt_log("[main] Traffic Server Args: '%s'\n", lmgmt->proxy_options); + lmgmt->proxy_options = new_proxy_opts; } - // we must pass in bind_stdout and bind_stderr values to TS - // we do it so TS is able to create BaseLogFiles for each value + // TS needs to be started up with the same outputlog bindings each time, + // so we append the outputlog location to the persistent proxy options + // + // TS needs them to be able to create BaseLogFiles for each value if (*bind_stdout != 0) { - size_t l = strlen(lmgmt->proxy_options); - size_t n = 3 /* " --" */ - + sizeof(TM_OPT_BIND_STDOUT) /* nul accounted for here */ - + 1 /* space */ - + strlen(bind_stdout); - lmgmt->proxy_options = static_cast<char *>(ats_realloc(lmgmt->proxy_options, n + l)); - snprintf(lmgmt->proxy_options + l, n, " --%s %s", TM_OPT_BIND_STDOUT, bind_stdout); + const char *bind_stdout_opt = " --" TM_OPT_BIND_STDOUT " "; + char *new_proxy_opts = new char[strlen(lmgmt->proxy_options) + strlen(bind_stdout_opt) + strlen(bind_stdout) + 1]; + strcpy(new_proxy_opts, lmgmt->proxy_options); + strcat(new_proxy_opts, bind_stdout_opt); + strcat(new_proxy_opts, bind_stdout); + delete lmgmt->proxy_options; + lmgmt->proxy_options = new_proxy_opts; } if (*bind_stderr != 0) { - size_t l = strlen(lmgmt->proxy_options); - size_t n = 3 /* space dash dash */ - + sizeof(TM_OPT_BIND_STDERR) /* nul accounted for here */ - + 1 /* space */ - + strlen(bind_stderr); - lmgmt->proxy_options = static_cast<char *>(ats_realloc(lmgmt->proxy_options, n + l)); - snprintf(lmgmt->proxy_options + l, n, " --%s %s", TM_OPT_BIND_STDERR, bind_stderr); + const char *bind_stderr_opt = " --" TM_OPT_BIND_STDERR " "; + char *new_proxy_opts = new char[strlen(lmgmt->proxy_options) + strlen(bind_stderr_opt) + strlen(bind_stderr) + 1]; + strcpy(new_proxy_opts, lmgmt->proxy_options); + strcat(new_proxy_opts, bind_stderr_opt); + strcat(new_proxy_opts, bind_stderr); + delete lmgmt->proxy_options; --- End diff -- You should not mix new/delete and malloc/free here. But this problem goes away with the text buffer.
--- If your project is set up for it, you can reply to this email and have your reply appear on GitHub as well. If your project does not have this feature enabled and wishes so, or if the feature is enabled but not working, please contact infrastructure at infrastruct...@apache.org or file a JIRA ticket with INFRA. ---