diff --git a/src/platforms/rcore_desktop_glfw.c b/src/platforms/rcore_desktop_glfw.c index 9b6881d40..70a820b3e 100644 --- a/src/platforms/rcore_desktop_glfw.c +++ b/src/platforms/rcore_desktop_glfw.c @@ -1190,8 +1190,14 @@ double GetTime(void) // REF: https://github.com/raysan5/raylib/issues/686 void OpenURL(const char *url) { - // Security check to (partially) avoid malicious code - if (strchr(url, '\'') != NULL) TRACELOG(LOG_WARNING, "SYSTEM: Provided URL could be potentially malicious, avoid [\'] character"); + // Security check to avoid malicious code injection + if (strchr(url, '\'') != NULL || strchr(url, '"') != NULL || + strchr(url, '&') != NULL || strchr(url, '|') != NULL || + strchr(url, ';') != NULL || strchr(url, '`') != NULL || + strchr(url, '$') != NULL || strchr(url, '\\') != NULL) + { + TRACELOG(LOG_WARNING, "SYSTEM: Provided URL contains potentially dangerous characters"); + } else { char *cmd = (char *)RL_CALLOC(strlen(url) + 32, sizeof(char)); diff --git a/src/raudio.c b/src/raudio.c index cd2ca2637..0cea63dab 100644 --- a/src/raudio.c +++ b/src/raudio.c @@ -1322,6 +1322,8 @@ float *LoadWaveSamples(Wave wave) { float *samples = (float *)RL_MALLOC(wave.frameCount*wave.channels*sizeof(float)); + if (samples == NULL) return NULL; + // NOTE: sampleCount is the total number of interlaced samples (including channels) for (unsigned int i = 0; i < wave.frameCount*wave.channels; i++) diff --git a/src/rtext.c b/src/rtext.c index 9bab4ba86..be7bc2a00 100644 --- a/src/rtext.c +++ b/src/rtext.c @@ -1612,7 +1612,12 @@ int TextToInteger(const char *text) text++; } - for (int i = 0; ((text[i] >= '0') && (text[i] <= '9')); i++) value = value*10 + (int)(text[i] - '0'); + for (int i = 0; ((text[i] >= '0') && (text[i] <= '9')); i++) + { + int digit = (int)(text[i] - '0'); + if (value > (INT_MAX - digit)/10) { value = INT_MAX; break; } // Overflow guard + value = value*10 + digit; + } } return value*sign; @@ -1724,7 +1729,7 @@ const char *TextRemoveSpaces(const char *text) if (text != NULL) { // Avoid copying the ' ' characters - for (int i = 0, j = 0; (i < MAX_TEXT_BUFFER_LENGTH - 1) && (text[j] != '\0'); i++) + for (int i = 0, j = 0; (i < MAX_TEXT_BUFFER_LENGTH - 1) && (text[i] != '\0'); i++) { if (text[i] != ' ') { buffer[j] = text[i]; j++; } }