From 50755c6a458f3e888417360f0c9d7b4a192bfb63 Mon Sep 17 00:00:00 2001 From: matthias gatto Date: Thu, 11 Oct 2018 23:56:27 +0200 Subject: [PATCH] ROMReader: fix specified bound depends on the length of the source argument It seems gcc have a (new ?) warning that doesn't allow *ncpy functions to have any source length related value as len argument. I've use strdunp to fix this, but I guess there is some other solutions that doesn't require free. use c++ strings ? use strcpy(...); tmp1[strlen(filename) - 4] = 0; ... ? remove the warning in the Makefile ? but as the strdump solution is simple enouth I've keep this. --- desmume/src/ROMReader.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/desmume/src/ROMReader.cpp b/desmume/src/ROMReader.cpp index 4e7a6a806..57e181fb9 100644 --- a/desmume/src/ROMReader.cpp +++ b/desmume/src/ROMReader.cpp @@ -238,12 +238,13 @@ void * ZIPROMReaderInit(const char * filename) ZZIP_DIRENT * dirent = zzip_readdir(dir); if (dir != NULL) { - char tmp1[1024]; + char *tmp1; char tmp2[1024]; - memset(tmp1,0,sizeof(tmp1)); + memset(tmp2,0,sizeof(tmp2)); - strncpy(tmp1, filename, strlen(filename) - 4); + tmp1 = strndup(filename, strlen(filename) - 4); sprintf(tmp2, "%s/%s", tmp1, dirent->d_name); + free(tmp1); return zzip_fopen(tmp2, "rb"); } return NULL;