Read_dir_callback(): prevent buffer overrun

This commit is contained in:
Thomas Bernard 2020-12-09 01:21:21 +01:00
parent 882a2892cf
commit aa19b5e748
No known key found for this signature in database
GPG Key ID: DB511043A31ACAAF

View File

@ -318,7 +318,7 @@ static void Read_dir_callback(void * pdata, const char *file_name, const word *u
{
int i;
pos_last_dot++;
for (i = 0; i < (int)sizeof(long_ext) - 1; i++)
for (i = 0; i < (int)sizeof(long_ext) - 1 && unicode_name[pos_last_dot + i] != 0; i++)
long_ext[i] = (unicode_name[pos_last_dot + i] < 256) ? unicode_name[pos_last_dot + i] : '?';
long_ext[i] = '\0';
file_name_ext = long_ext;