From 1362c73a7e965ed9cd6efe0cc86aebd1f4e4708b Mon Sep 17 00:00:00 2001 From: Andy McFadden Date: Fri, 9 Jan 2015 18:19:14 -0800 Subject: [PATCH] Gutenberg tweaks Changed the catalog scan offset so we don't overrun the buffer. Changed a strcpy() to strncpy(). Added Gutenberg to the list of formats MDC outputs. --- diskimg/Gutenberg.cpp | 2 +- linux/MDC.cpp | 10 +++++++--- mdc/Main.cpp | 3 +++ 3 files changed, 11 insertions(+), 4 deletions(-) diff --git a/diskimg/Gutenberg.cpp b/diskimg/Gutenberg.cpp index 1dc10e6..e64fb8e 100644 --- a/diskimg/Gutenberg.cpp +++ b/diskimg/Gutenberg.cpp @@ -22,7 +22,7 @@ const int kMaxVolNameLen = 9; const int kSctSize = 256; const int kVTOCTrack = 17; const int kVTOCSector = 7; -const int kCatalogEntryOffset = 0x20; // first entry in cat sect starts here +const int kCatalogEntryOffset = 0x10; // first entry in cat sect starts here const int kCatalogEntrySize = 16; // length in bytes of catalog entries const int kCatalogEntriesPerSect = 15; // #of entries per catalog sector const int kEntryDeleted = 0x40; // this is used to designate deleted files diff --git a/linux/MDC.cpp b/linux/MDC.cpp index 4eb50cd..ce62b9d 100644 --- a/linux/MDC.cpp +++ b/linux/MDC.cpp @@ -348,9 +348,10 @@ LoadDiskFSContents(DiskFS* pDiskFS, const char* volName, if (strlen(ccp) == 0) ccp = kBlankFileName; - if (subVolName[0] == '\0') - strcpy(dispName, ccp); - else { + if (subVolName[0] == '\0') { + strncpy(dispName, ccp, sizeof(dispName)); + dispName[sizeof(dispName) - 1] = '\0'; + } else { snprintf(dispName, sizeof(dispName), "%s:%s", subVolName, ccp); //dispName = subVolName; //dispName += ':'; @@ -470,6 +471,9 @@ LoadDiskFSContents(DiskFS* pDiskFS, const char* volName, case DiskImg::kFormatRDOS3: fmtStr = "RDOS "; break; + case DiskImg::kFormatGutenberg: + fmtStr = "Gutenb"; + break; default: fmtStr = "??? "; break; diff --git a/mdc/Main.cpp b/mdc/Main.cpp index 5fd9f87..b3c7266 100644 --- a/mdc/Main.cpp +++ b/mdc/Main.cpp @@ -856,6 +856,9 @@ int MainWindow::LoadDiskFSContents(DiskFS* pDiskFS, const char* volName, case DiskImg::kFormatMSDOS: fmtStr = "MS-DOS"; break; + case DiskImg::kFormatGutenberg: + fmtStr = "Gutenb"; + break; default: fmtStr = "??? "; break;