blenlib: BLI_file_attributes() Correction

Adds an Correction to properly handle possibility of overflow of path name.

Differential Revision: https://developer.blender.org/D7739

Reviewed by Brecht Van Lommel
This commit is contained in:
Harley Acheson 2020-05-15 08:10:57 -07:00
parent 0f2c7f3864
commit b14243be77
1 changed files with 3 additions and 2 deletions

View File

@ -233,8 +233,9 @@ eFileAttributes BLI_file_attributes(const char *path)
# ifdef WIN32
WCHAR wline[FILE_MAXDIR];
size_t bsize = count_utf_16_from_8(path);
conv_utf_8_to_16(path, wline, bsize);
if (conv_utf_8_to_16(path, wline, ARRAY_SIZE(wline)) != 0) {
return ret;
}
DWORD attr = GetFileAttributesW(wline);
if (attr & FILE_ATTRIBUTE_READONLY) {
ret |= FILE_ATTR_READONLY;