瀏覽代碼

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 3 年之前
committed by GitHub
父節點
當前提交
e0b487c641
沒有發現已知的金鑰在資料庫的簽署中 GPG 金鑰 ID: 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++)

Loading…
取消
儲存