imgread/gdi.cpp: Fix buffer overflow in load_gdi()

This commit is contained in:
Jan Holthuis 2016-02-22 18:40:11 +01:00
parent b106efde5f
commit 1868f1e91f
1 changed files with 6 additions and 2 deletions

View File

@ -31,9 +31,13 @@ Disc* load_gdi(const char* file)
gdi >> iso_tc;
printf("\nGDI : %d tracks\n",iso_tc);
// FIXME: Data loss if buffer is too small
char path[512];
strcpy(path,file);
size_t len=strlen(file);
strncpy(path, file, sizeof(path));
path[sizeof(path) - 1] = '\0';
size_t len = strlen(path);
while (len>2)
{
if (path[len]=='\\' || path[len]=='/')