From: Joachim Protze Date: Mon, 29 Jun 2020 10:43:41 +0000 (+0200) Subject: [OpenMP][Tool] Fix buffer overflow in ompt-multiplex.h X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=d4230c67bf8a2b4f9c4d80898f54fd00db719ae9;p=platform%2Fupstream%2Fllvm.git [OpenMP][Tool] Fix buffer overflow in ompt-multiplex.h Reviewed by: runlieb Differential Revision: https://reviews.llvm.org/D82452 --- diff --git a/openmp/tools/multiplex/ompt-multiplex.h b/openmp/tools/multiplex/ompt-multiplex.h index 097b737..e16189f 100644 --- a/openmp/tools/multiplex/ompt-multiplex.h +++ b/openmp/tools/multiplex/ompt-multiplex.h @@ -26,6 +26,7 @@ #include #include #include +#include static ompt_set_callback_t ompt_multiplex_set_callback; static ompt_get_task_info_t ompt_multiplex_get_task_info; @@ -1040,12 +1041,11 @@ ompt_start_tool_result_t *ompt_start_tool(unsigned int omp_version, const char *tool_libs = getenv(CLIENT_TOOL_LIBRARIES_VAR); if (tool_libs) { // copy environement variable - char *tool_libs_buffer = (char *)malloc(sizeof(char) * strlen(tool_libs)); + char *tool_libs_buffer = strdup(tool_libs); if (!tool_libs_buffer) { - printf("malloc Error\n"); + printf("strdup Error (%i)\n", errno); exit(-1); } - strcpy(tool_libs_buffer, tool_libs); int progress = 0; while (progress < strlen(tool_libs)) {