Blob Blame History Raw
From befd13284bf2c46fd00b7406855dbe062cb5d1aa Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Bj=C3=B6rn=20Esser?= <besser82@fedoraproject.org>
Date: Fri, 21 Jun 2019 20:18:10 +0200
Subject: [PATCH 30/36] cc1541: Fix segfault with GCC 8 and -O2.

---
 cc1541.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/cc1541.c b/cc1541.c
index a07e2ab..66e6397 100644
--- a/cc1541.c
+++ b/cc1541.c
@@ -62,7 +62,7 @@
 typedef struct
 {
     char* localname;
-    char filename[FILENAMEMAXSIZE];
+    char filename[FILENAMEMAXSIZE + 1];
     int loopindex;
     int direntryindex;
     int direntrysector;
@@ -1521,6 +1521,7 @@ main(int argc, char* argv[])
                 evalhexescape(filename);
                 strncpy(files[nrFiles].filename, filename, FILENAMEMAXSIZE);
             }
+            files[nrFiles].filename[FILENAMEMAXSIZE] = '\0';
             files[nrFiles].sectorInterleave = sectorInterleave ? sectorInterleave : defaultSectorInterleave;
             files[nrFiles].first_sector_new_track = first_sector_new_track;
             files[nrFiles].nrSectorsShown = nrSectorsShown;
-- 
2.21.0