summaryrefslogtreecommitdiffhomepage
path: root/src
diff options
context:
space:
mode:
authorRay <[email protected]>2023-03-15 13:03:55 +0100
committerRay <[email protected]>2023-03-15 13:03:55 +0100
commitad2067340ffd601873b8c0d658a16e1ef3a98624 (patch)
tree533454c52a9c62eaee1b916e73242071a699d387 /src
parentcf04425bc2afcf8da998d8c5d24a320cf8a076bb (diff)
downloadraylib-ad2067340ffd601873b8c0d658a16e1ef3a98624.tar.gz
raylib-ad2067340ffd601873b8c0d658a16e1ef3a98624.zip
REVIEWED: `TraceLog()`, avoid possible buffer overflow
Diffstat (limited to 'src')
-rw-r--r--src/utils.c5
1 files changed, 3 insertions, 2 deletions
diff --git a/src/utils.c b/src/utils.c
index 6843bd94..771271d3 100644
--- a/src/utils.c
+++ b/src/utils.c
@@ -54,7 +54,7 @@
// Defines and Macros
//----------------------------------------------------------------------------------
#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
//----------------------------------------------------------------------------------
@@ -145,7 +145,8 @@ void TraceLog(int logType, const char *text, ...)
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");
vprintf(buffer, args);
fflush(stdout);