Просмотр исходного кода

Fix string lacking null termination in IsFileExtension (#2637)

When file extension is longer or equal length compared to buffer holding lowercased string, strncpy does not null terminate the string.
Increased buffer size by 1 to ensure it will always be null-terminated, so that following strcmp does not read out of buffer bounds.
pull/2905/head
HarriP 2 лет назад
committed by GitHub
Родитель
Сommit
e0b487c641
Не найден GPG ключ соответствующий данной подписи Идентификатор GPG ключа: 4AEE18F83AFDEB23
1 измененных файлов: 1 добавлений и 1 удалений
  1. +1
    -1
      src/rcore.c

+ 1
- 1
src/rcore.c Просмотреть файл

@ -2842,7 +2842,7 @@ bool IsFileExtension(const char *fileName, const char *ext)
int extCount = 0;
const char **checkExts = TextSplit(ext, ';', &extCount); // WARNING: Module required: rtext
char fileExtLower[MAX_FILE_EXTENSION_SIZE] = { 0 };
char fileExtLower[MAX_FILE_EXTENSION_SIZE + 1] = { 0 };
strncpy(fileExtLower, TextToLower(fileExt),MAX_FILE_EXTENSION_SIZE); // WARNING: Module required: rtext
for (int i = 0; i < extCount; i++)

||||||
x
 
000:0
Загрузка…
Отмена
Сохранить