diff --git a/src/dos/cdrom.h b/src/dos/cdrom.h index c4382092..173a9c24 100644 --- a/src/dos/cdrom.h +++ b/src/dos/cdrom.h @@ -5,8 +5,11 @@ #define MAX_ASPI_CDROM 5 #include +#include #include #include +#include +#include #include "dosbox.h" #include "mem.h" #include "mixer.h" diff --git a/src/dos/cdrom_image.cpp b/src/dos/cdrom_image.cpp index ad6686e2..e14357c3 100644 --- a/src/dos/cdrom_image.cpp +++ b/src/dos/cdrom_image.cpp @@ -16,14 +16,14 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ -/* $Id: cdrom_image.cpp,v 1.3 2004-08-23 09:35:15 harekiet Exp $ */ +/* $Id: cdrom_image.cpp,v 1.4 2004-10-05 19:55:03 qbix79 Exp $ */ #include #include #include #include #include -#include +#include #include #include #include @@ -572,7 +572,7 @@ bool CDROM_Interface_Image::GetRealFileName(string &filename, string &pathname) if (stat(filename.c_str(), &test) == 0) return true; // check if file with path relative to cue file exists -#if not defined(WIN32) +#ifndef WIN32 string tmpstr(pathname + "/" + filename); if (stat(tmpstr.c_str(), &test) == 0) { filename = tmpstr; diff --git a/src/dos/drive_iso.cpp b/src/dos/drive_iso.cpp index d58ec954..0127ec7c 100644 --- a/src/dos/drive_iso.cpp +++ b/src/dos/drive_iso.cpp @@ -16,7 +16,7 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ -/* $Id: drive_iso.cpp,v 1.1 2004-08-13 19:43:02 qbix79 Exp $ */ +/* $Id: drive_iso.cpp,v 1.2 2004-10-05 19:55:03 qbix79 Exp $ */ #include #include @@ -152,7 +152,29 @@ isoDrive::isoDrive(char driveLetter, const char *fileName, Bit8u mediaid, int &e searchCache.clear(); dirIter = searchCache.end(); this->mediaid = mediaid; - if (!MSCDEX_GetVolumeName(subUnit, discLabel)) strcpy(discLabel, ""); + char buffer[32] = { 0 }; + if (!MSCDEX_GetVolumeName(subUnit, buffer)) strcpy(buffer, ""); + + //Code Copied from drive_cache. (convert mscdex label to a dos 8.3 file) + Bitu togo = 8; + Bitu bufPos = 0; + Bitu labelPos = 0; + bool point = false; + while (togo>0) { + if (buffer[bufPos]==0) break; + if (!point && (buffer[bufPos]=='.')) { togo=4; point=true; } + discLabel[labelPos] = toupper(buffer[bufPos]); + labelPos++; bufPos++; + togo--; + if ((togo==0) && !point) { + if (buffer[bufPos]=='.') bufPos++; + discLabel[labelPos]='.'; labelPos++; point=true; togo=3; + } + }; + discLabel[labelPos]=0; + //Remove trailing dot. + if((labelPos > 0) && (discLabel[labelPos - 1] == '.')) + discLabel[labelPos - 1] = 0; } else error = 6; } } @@ -229,7 +251,7 @@ bool isoDrive::FindFirst(char *dir, DOS_DTA &dta, bool fcb_findfirst) readSector(block, sector); Bit32u pos = 0; - while (pos < ISO_FRAMESIZE && block[pos] != 0) { + while (block[pos] != 0 && (pos + block[pos]) < ISO_FRAMESIZE) { isoDirEntry tmp; int length = readDirEntry(&tmp, &block[pos]); if (length < 0) return false; @@ -353,6 +375,7 @@ inline bool isoDrive :: readSector(Bit8u *buffer, Bit32u sector) int isoDrive :: readDirEntry(isoDirEntry *de, Bit8u *data) { // copy data into isoDirEntry struct, data[0] = length of DirEntry + if (data[0] > sizeof(isoDirEntry)) return -1; memcpy(de, data, data[0]); // xa not supported @@ -361,6 +384,7 @@ int isoDrive :: readDirEntry(isoDirEntry *de, Bit8u *data) if (de->fileUnitSize != 0 || de->interleaveGapSize != 0) return -1; // modify file identifier for use with dosbox + if ((de->length < 33 + de->fileIdentLength)) return -1; if (IS_DIR(de->fileFlags)) { if (de->fileIdentLength == 1 && de->ident[0] == 0) strcpy((char*)de->ident, "."); else if (de->fileIdentLength == 1 && de->ident[0] == 1) strcpy((char*)de->ident, ".."); @@ -375,6 +399,7 @@ int isoDrive :: readDirEntry(isoDirEntry *de, Bit8u *data) strreplace((char*)de->ident, ';', 0); // if file has no extension remove the trailing dot int tmp = strlen((char*)de->ident); +//if (tmp > 38) return -1; //de->ident can hold 100 if (tmp > 0 && de->ident[tmp - 1] == '.') de->ident[tmp - 1] = 0; } return de->length; @@ -398,7 +423,7 @@ bool isoDrive :: lookupSingle(isoDirEntry *de, const char *name, Bit32u start, B if (!readSector(sector, i)) return false; int pos = 0; - while (sector[pos] != 0 && pos < ISO_FRAMESIZE) { + while (sector[pos] != 0 && (pos + sector[pos]) < ISO_FRAMESIZE) { int deLength = readDirEntry(de, §or[pos]); if (deLength < 1) return false; pos += deLength; @@ -423,6 +448,8 @@ bool isoDrive :: lookup(isoDirEntry *de, const char *path) while (isoPath[pos] != 0) { if (isoPath[pos] == '/') { char name[38]; + if (pos - beginPos >= 38) return false; + if (beginPos >= ISO_MAXPATHNAME) return false; strncpy(name, &isoPath[beginPos], pos - beginPos); name[pos - beginPos] = 0; beginPos = pos + 1; diff --git a/src/dos/drives.h b/src/dos/drives.h index ecde6b4e..e5de809f 100644 --- a/src/dos/drives.h +++ b/src/dos/drives.h @@ -16,7 +16,7 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ -/* $Id: drives.h,v 1.23 2004-08-13 19:43:02 qbix79 Exp $ */ +/* $Id: drives.h,v 1.24 2004-10-05 19:55:03 qbix79 Exp $ */ #ifndef _DRIVES_H__ #define _DRIVES_H__ @@ -254,7 +254,7 @@ struct isoDirEntry { Bit16u VolumeSeqNumberL; Bit16u VolumeSeqNumberM; Bit8u fileIdentLength; - Bit8u ident[38]; // can be smaller + Bit8u ident[100]; } GCC_ATTRIBUTE(packed); #ifdef _MSC_VER