cxong / tinydir

Lightweight, portable and easy to integrate C directory and file reader

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

MSVC and tinydir_file_open

jernejsk opened this issue · comments

There is an issue in tinydir_file_open when compiled with MSVC.

At the beginning of the function, there is following declaration:

_tinydir_char_t drive_buf[_TINYDIR_DRIVE_MAX];

_TINYDIR_DRIVE_MAX is defined as 3

Later on, there is following line:

_tinydir_strcat(drive_buf, dir_name_buf);

which always overflows the buffer.

Quick solution is to define drive_buf as

_tinydir_char_t drive_buf[_TINYDIR_PATH_MAX];
commented

good catch!