Skip to content

Commit e6843aa

Browse files
authored
Merge branch 'raysan5:master' into master
2 parents cba3669 + 749a512 commit e6843aa

File tree

2 files changed

+21
-6
lines changed

2 files changed

+21
-6
lines changed

src/external/jar_xm.h

+7
Original file line numberDiff line numberDiff line change
@@ -232,6 +232,13 @@ uint64_t jar_xm_get_remaining_samples(jar_xm_context_t* ctx);
232232
#include <limits.h>
233233
#include <string.h>
234234

235+
#ifdef DEBUG
236+
// Undefine DEBUG to avoid external redefinition warnings/conflicts
237+
// This is probably a common definition for
238+
// many external build systems' debug configurations
239+
#undef DEBUG
240+
#endif
241+
235242
#if JAR_XM_DEBUG //JAR_XM_DEBUG defined as 0
236243
#include <stdio.h>
237244
#define DEBUG(fmt, ...) do { \

src/rcore.c

+14-6
Original file line numberDiff line numberDiff line change
@@ -3688,12 +3688,16 @@ static void ScanDirectoryFiles(const char *basePath, FilePathList *files, const
36883688
(strcmp(dp->d_name, "..") != 0))
36893689
{
36903690
#if defined(_WIN32)
3691-
sprintf(path, "%s\\%s", basePath, dp->d_name);
3691+
int pathLength = snprintf(path, MAX_FILEPATH_LENGTH - 1, "%s\\%s", basePath, dp->d_name);
36923692
#else
3693-
sprintf(path, "%s/%s", basePath, dp->d_name);
3693+
int pathLength = snprintf(path, MAX_FILEPATH_LENGTH - 1, "%s/%s", basePath, dp->d_name);
36943694
#endif
36953695

3696-
if (filter != NULL)
3696+
if ((pathLength < 0) || (pathLength >= MAX_FILEPATH_LENGTH))
3697+
{
3698+
TRACELOG(LOG_WARNING, "FILEIO: Path longer than %d characters (%s...)", MAX_FILEPATH_LENGTH, basePath);
3699+
}
3700+
else if (filter != NULL)
36973701
{
36983702
if (IsPathFile(path))
36993703
{
@@ -3742,12 +3746,16 @@ static void ScanDirectoryFilesRecursively(const char *basePath, FilePathList *fi
37423746
{
37433747
// Construct new path from our base path
37443748
#if defined(_WIN32)
3745-
sprintf(path, "%s\\%s", basePath, dp->d_name);
3749+
int pathLength = snprintf(path, MAX_FILEPATH_LENGTH - 1, "%s\\%s", basePath, dp->d_name);
37463750
#else
3747-
sprintf(path, "%s/%s", basePath, dp->d_name);
3751+
int pathLength = snprintf(path, MAX_FILEPATH_LENGTH - 1, "%s/%s", basePath, dp->d_name);
37483752
#endif
37493753

3750-
if (IsPathFile(path))
3754+
if ((pathLength < 0) || (pathLength >= MAX_FILEPATH_LENGTH))
3755+
{
3756+
TRACELOG(LOG_WARNING, "FILEIO: Path longer than %d characters (%s...)", MAX_FILEPATH_LENGTH, basePath);
3757+
}
3758+
else if (IsPathFile(path))
37513759
{
37523760
if (filter != NULL)
37533761
{

0 commit comments

Comments
 (0)