Merge pull request #510 from vel21ripn/dev

Fix buffer overflow in function ndpi_debug_printf()
This commit is contained in:
Michele Campus
2018-01-26 15:04:38 +01:00
committed by GitHub
+2 -2
View File
@@ -1950,13 +1950,13 @@ void ndpi_debug_printf(unsigned int proto, struct ndpi_detection_module_struct *
{ {
#ifdef NDPI_ENABLE_DEBUG_MESSAGES #ifdef NDPI_ENABLE_DEBUG_MESSAGES
va_list args; va_list args;
#define MAX_STR_LEN 120 #define MAX_STR_LEN 250
char str[MAX_STR_LEN]; char str[MAX_STR_LEN];
if(ndpi_str != NULL && log_level > NDPI_LOG_ERROR && if(ndpi_str != NULL && log_level > NDPI_LOG_ERROR &&
proto > 0 && proto < NDPI_MAX_SUPPORTED_PROTOCOLS && proto > 0 && proto < NDPI_MAX_SUPPORTED_PROTOCOLS &&
!NDPI_ISSET(&ndpi_str->debug_bitmask,proto)) return; !NDPI_ISSET(&ndpi_str->debug_bitmask,proto)) return;
va_start(args, format); va_start(args, format);
vsprintf(str, format, args); vsnprintf(str,sizeof(str)-1, format, args);
va_end(args); va_end(args);
if (ndpi_str != NULL) { if (ndpi_str != NULL) {