Fix: lib-logging: possible buffer not null terminated
[babeltrace.git] / lib / lib-logging.c
index 0a988db3d3f2d2c5ec2c9e204a8c00039aaea1a1..98572f161d4a8a5b2d9c1fd574f2d71ac4a8d887 100644 (file)
@@ -103,8 +103,9 @@ static __thread char lib_logging_buf[LIB_LOGGING_BUF_SIZE];
 #define TMP_PREFIX_LEN 64
 #define SET_TMP_PREFIX(_prefix2)                                       \
        do {                                                            \
 #define TMP_PREFIX_LEN 64
 #define SET_TMP_PREFIX(_prefix2)                                       \
        do {                                                            \
-               strncpy(tmp_prefix, prefix, TMP_PREFIX_LEN);            \
-               strncat(tmp_prefix, (_prefix2), TMP_PREFIX_LEN);        \
+               snprintf(tmp_prefix, TMP_PREFIX_LEN - 1, "%s%s",        \
+                       prefix, (_prefix2));                            \
+               tmp_prefix[TMP_PREFIX_LEN - 1] = '\0';                  \
        } while (0)
 
 static inline void format_component(char **buf_ch, bool extended,
        } while (0)
 
 static inline void format_component(char **buf_ch, bool extended,
This page took 0.023437 seconds and 4 git commands to generate.