Quellcode durchsuchen

LOG4C_HEX_DUMP有Bug:
char strBuffer[128] = "You are the Best One!\0 Yes.";
LOG4C_HEX_DUMP((LOG_INFO, strBuffer, sizeof(strBuffer)));

此时strBuffer中没有'%'字符,不会出问题。
但是,如果strBuffer中存在'%'字符,则会导致程序崩溃。

Jeff vor 6 Jahren
Ursprung
Commit
4f2e432ea9
1 geänderte Dateien mit 32 neuen und 26 gelöschten Zeilen
  1. 32 26
      log4cproj_c/Log4C/log.c

+ 32 - 26
log4cproj_c/Log4C/log.c

@@ -351,17 +351,17 @@ void log_msg_func(
 	}
 }
 
-/** 日志记录,不记录文件名和行号
-日志记录为一个字符串指针指向的内容
-@return void
-作者:jesse  日期:2008-2-3
-*/
-void log_msg_no_file_num(
-						 const char *strCatName,	///category名
-						 const int iPriority,		///日志记录级别
-						 const char *strFormat,		///日志内容格式
-						 ...						///日志内容
-						 )
+/************************************************************************/
+/*  函数:[3/30/2019 Wang];
+/*  描述:日志记录,不记录文件名和行号,日志记录为一个字符串指针指向的内容;
+/*  参数:;
+/*  	[IN] strCatName:category名;
+/*  	[IN] iPriority:日志记录级别;
+/*  	[IN] strFormat:日志内容格式;
+/*  	[IN] ...:日志内容;
+/*  返回:void;
+/************************************************************************/
+void log_msg_no_file_num(const char *strCatName, const int iPriority, const char *strFormat, ...)
 {
 	const log4c_category_t* a_category = log4c_category_get(strCatName);
 	if (log4c_category_is_priority_enabled(a_category, iPriority)) 
@@ -552,27 +552,33 @@ const LOG_PARAM  log_condition_vsnprintf_wrapper(
 	return log_param;
 }
 
-void log_hex_dump_vsnprintf_wrapper(
-									const int iPriority,	///日志记录级别
-									const char* strHexBuf,		///缓冲区首地址
-									const int iHexBufLen,		///缓冲区长度
-									...						///日志内容
-									)
+/************************************************************************/
+/*  函数:[3/30/2019 Wang];
+/*  描述:;
+/*  参数:;
+/*  	[IN] iPriority:日志记录级别;
+/*  	[IN] strHexBuf:缓冲区首地址;
+/*  	[IN] iHexBufLen:缓冲区长度;
+/*  	[IN] ...:日志内容;
+/*  返回:void;
+/************************************************************************/
+void log_hex_dump_vsnprintf_wrapper(const int iPriority, const char* strHexBuf, const int iHexBufLen, ...)
 {
 	char *strBuffer = (char *)malloc(LOG4C_BUFFER_SIZE_MAX);
 	memset(strBuffer, 0, LOG4C_BUFFER_SIZE_MAX);
 	log4c_sprintf_data((char*)(strHexBuf), (iHexBufLen), strBuffer);
-	log_msg_no_file_num(
-		DEFAULT_LOG_CATEGORY_NAME, 
-		iPriority, 
-		strBuffer 
-		); 
+	log_msg_no_file_num(DEFAULT_LOG_CATEGORY_NAME, iPriority, strBuffer ); 
 }
 
-const LOG_PARAM  log_vsnprintf_wrapper_msg(
-	const char* strFormat,	///日志内容格式
-	...						///日志内容
-	)
+/************************************************************************/
+/*  函数:[3/30/2019 Wang];
+/*  描述:;
+/*  参数:;
+/*  	[IN] strFormat:日志内容格式;
+/*  	[IN] ...:日志内容;
+/*  返回:void;
+/************************************************************************/
+const LOG_PARAM  log_vsnprintf_wrapper_msg(const char* strFormat, ...)
 {
 	LOG_PARAM log_param;