ttrace: replace sprintf with snprintf 79/216179/2 submit/tizen/20191022.050108
authorWonki Kim <wonki_.kim@samsung.com>
Tue, 22 Oct 2019 04:53:03 +0000 (13:53 +0900)
committerwonki kim <wonki_.kim@samsung.com>
Tue, 22 Oct 2019 04:56:13 +0000 (04:56 +0000)
sprintf has a potentiality of BOF.
this patch replace it with snprintf to prevent the problem.

Change-Id: Id131277846519ecd6deae363a3da3d363590567a
Signed-off-by: Wonki Kim <wonki_.kim@samsung.com>
tracing/efl_tracing.h

index 44c7521..8a0cfe8 100644 (file)
 
 #include <ttrace.h>
 
+#define TTRACE_LOG_BUF_SIZE 500
+
 static inline void _ttrace_append_domain(const char *name, const char *data)
 {
-   char buf[500];
+   char buf[TTRACE_LOG_BUF_SIZE];
 
    if (data)
      {
-        sprintf(buf,"%s::%s", name,data);
+        snprintf(buf, TTRACE_LOG_BUF_SIZE, "%s::%s", name,data);
         traceBegin(TTRACE_TAG_EFL, buf);
      }
    else
@@ -49,14 +51,14 @@ static inline void _vtune_task_start(const char *name)
 
 static inline void _vtune_append_domain(const char *name, const char *data)
 {
-   char buf[500];
+   char buf[TTRACE_LOG_BUF_SIZE];
 
    if (!_vtune_efl_domain) _vtune_efl_domain = __itt_domain_create("EFL");
 
    if (data)
-     sprintf(buf,"%s::%s", name,data);
+     snprintf(buf, TTRACE_LOG_BUF_SIZE, "%s::%s", name,data);
    else
-     sprintf(buf,"%s", name);
+     snprintf(buf, TTRACE_LOG_BUF_SIZE, "%s", name);
 
    __itt_task_begin(_vtune_efl_domain, __itt_null, __itt_null,
                     __itt_string_handle_create(buf));
@@ -91,4 +93,4 @@ static inline void _vtune_frame_start()
 
 #define traceFrameEnd()
 
-#endif
\ No newline at end of file
+#endif