mirror of
https://github.com/raysan5/raylib.git
synced 2026-01-24 08:09:18 -05:00
ADDED: Multiply security checks to avoid crashes on wrongly provided string data #4751
- REVIEWED: Checking `NULL` input on functions getting `const char *text`, to avoid crashes - REVIEWED: `strcpy()` usage, prioritize `strncpy()` with limited copy to buffer size - REPLACED: `strlen()` by `TextLength()` on [rtext] module - REVIEWED: Replaced some early returns (but keeping others, for easier code following)
This commit is contained in:
@ -2492,12 +2492,12 @@ void rlLoadExtensions(void *loader)
|
||||
const char *extensions = (const char *)glGetString(GL_EXTENSIONS); // One big const string
|
||||
|
||||
// NOTE: We have to duplicate string because glGetString() returns a const string
|
||||
int size = strlen(extensions) + 1; // Get extensions string size in bytes
|
||||
char *extensionsDup = (char *)RL_CALLOC(size, sizeof(char));
|
||||
strcpy(extensionsDup, extensions);
|
||||
int extSize = (int)strlen(extensions); // Get extensions string size in bytes
|
||||
char *extensionsDup = (char *)RL_CALLOC(extSize + 1, sizeof(char)); // Allocate space for copy with additional EOL byte
|
||||
strncpy(extensionsDup, extensions, extSize);
|
||||
extList[numExt] = extensionsDup;
|
||||
|
||||
for (int i = 0; i < size; i++)
|
||||
for (int i = 0; i < extSize; i++)
|
||||
{
|
||||
if (extensionsDup[i] == ' ')
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user