소스 검색

REVIEWED: `TraceLog()`, avoid possible buffer overflow

pull/2958/head
Ray 2 년 전
부모
커밋
ad2067340f
1개의 변경된 파일3개의 추가작업 그리고 2개의 파일을 삭제
  1. +3
    -2
      src/utils.c

+ 3
- 2
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);

불러오는 중...
취소
저장