REVIEWED: TraceLog()
, avoid possible buffer overflow
This commit is contained in:
parent
cf04425bc2
commit
ad2067340f
1 changed files with 3 additions and 2 deletions
|
@ -54,7 +54,7 @@
|
||||||
// Defines and Macros
|
// Defines and Macros
|
||||||
//----------------------------------------------------------------------------------
|
//----------------------------------------------------------------------------------
|
||||||
#ifndef MAX_TRACELOG_MSG_LENGTH
|
#ifndef MAX_TRACELOG_MSG_LENGTH
|
||||||
#define MAX_TRACELOG_MSG_LENGTH 128 // Max length of one trace-log message
|
#define MAX_TRACELOG_MSG_LENGTH 256 // Max length of one trace-log message
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
//----------------------------------------------------------------------------------
|
//----------------------------------------------------------------------------------
|
||||||
|
@ -145,7 +145,8 @@ void TraceLog(int logType, const char *text, ...)
|
||||||
default: break;
|
default: break;
|
||||||
}
|
}
|
||||||
|
|
||||||
strcat(buffer, text);
|
unsigned int textSize = strlen(text);
|
||||||
|
memcpy(buffer + strlen(buffer), text, (textSize < (MAX_TRACELOG_MSG_LENGTH - 12))? textSize : (MAX_TRACELOG_MSG_LENGTH - 12));
|
||||||
strcat(buffer, "\n");
|
strcat(buffer, "\n");
|
||||||
vprintf(buffer, args);
|
vprintf(buffer, args);
|
||||||
fflush(stdout);
|
fflush(stdout);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue