[Fix] Avoid possible out of bounds memory access.
This commit is contained in:
parent
ee7667be6d
commit
252f2f87b7
4
src/ai.c
4
src/ai.c
@ -389,7 +389,9 @@ int ai_init(void) {
|
|||||||
suflen = strlen(AI_SUFFIX);
|
suflen = strlen(AI_SUFFIX);
|
||||||
for(i = 0; i < nfiles; i++) {
|
for(i = 0; i < nfiles; i++) {
|
||||||
flen = strlen(files[i]);
|
flen = strlen(files[i]);
|
||||||
if(strncmp(&files[i][flen-suflen], AI_SUFFIX, suflen)==0) {
|
if((flen > suflen) &&
|
||||||
|
strncmp(&files[i][flen-suflen], AI_SUFFIX, suflen)==0) {
|
||||||
|
|
||||||
snprintf(path, PATH_MAX, AI_PREFIX"%s", files[i]);
|
snprintf(path, PATH_MAX, AI_PREFIX"%s", files[i]);
|
||||||
if(ai_loadProfile(path)) /* Load the profile. */
|
if(ai_loadProfile(path)) /* Load the profile. */
|
||||||
WARN("Error loading AI profile '%s'", path);
|
WARN("Error loading AI profile '%s'", path);
|
||||||
|
@ -180,7 +180,9 @@ static int music_find(void) {
|
|||||||
suflen = strlen(MUSIC_SUFFIX);
|
suflen = strlen(MUSIC_SUFFIX);
|
||||||
for(i = 0; i < nfiles; i++) {
|
for(i = 0; i < nfiles; i++) {
|
||||||
flen = strlen(files[i]);
|
flen = strlen(files[i]);
|
||||||
if(strncmp(&files[i][flen - suflen], MUSIC_SUFFIX, suflen)==0) {
|
if((flen > suflen) &&
|
||||||
|
strncmp(&files[i][flen - suflen], MUSIC_SUFFIX, suflen)==0) {
|
||||||
|
|
||||||
/* Grow the selection size. */
|
/* Grow the selection size. */
|
||||||
nmusic_selection++;
|
nmusic_selection++;
|
||||||
if(nmusic_selection > mem) {
|
if(nmusic_selection > mem) {
|
||||||
|
@ -442,8 +442,8 @@ static int sound_makeList(void) {
|
|||||||
suflen = strlen(SOUND_SUFFIX);
|
suflen = strlen(SOUND_SUFFIX);
|
||||||
for(i = 0; i < nfiles; i++) {
|
for(i = 0; i < nfiles; i++) {
|
||||||
flen = strlen(files[i]);
|
flen = strlen(files[i]);
|
||||||
if(strncmp(&files[i][flen - suflen],
|
if((flen > suflen) &&
|
||||||
SOUND_SUFFIX, suflen)==0) {
|
strncmp(&files[i][flen - suflen], SOUND_SUFFIX, suflen)==0) {
|
||||||
|
|
||||||
/* Expand the selection size. */
|
/* Expand the selection size. */
|
||||||
sound_nlist++;
|
sound_nlist++;
|
||||||
|
Loading…
Reference in New Issue
Block a user