diff --git a/src/common/FSNodeZIP.cxx b/src/common/FSNodeZIP.cxx index abab6ce0e..a29b3fc49 100644 --- a/src/common/FSNodeZIP.cxx +++ b/src/common/FSNodeZIP.cxx @@ -180,7 +180,7 @@ bool FilesystemNodeZIP::getChildren(AbstractFSList& myList, ListMode mode) const } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -uInt32 FilesystemNodeZIP::read(ByteBuffer& image) const +size_t FilesystemNodeZIP::read(ByteBuffer& image) const { switch(_error) { diff --git a/src/common/FSNodeZIP.hxx b/src/common/FSNodeZIP.hxx index 951f85a2d..0bb4ae0eb 100644 --- a/src/common/FSNodeZIP.hxx +++ b/src/common/FSNodeZIP.hxx @@ -67,7 +67,7 @@ class FilesystemNodeZIP : public AbstractFSNode bool getChildren(AbstractFSList& list, ListMode mode) const override; AbstractFSNodePtr getParent() const override; - uInt32 read(ByteBuffer& image) const override; + size_t read(ByteBuffer& image) const override; private: FilesystemNodeZIP(const string& zipfile, const string& virtualpath, diff --git a/src/emucore/FSNode.cxx b/src/emucore/FSNode.cxx index 21ed192da..19bffb38c 100644 --- a/src/emucore/FSNode.cxx +++ b/src/emucore/FSNode.cxx @@ -214,9 +214,9 @@ bool FilesystemNode::rename(const string& newfile) } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -uInt32 FilesystemNode::read(ByteBuffer& image) const +size_t FilesystemNode::read(ByteBuffer& image) const { - uInt32 size = 0; + size_t size = 0; // File must actually exist if (!(exists() && isReadable())) @@ -238,7 +238,7 @@ uInt32 FilesystemNode::read(ByteBuffer& image) const if (length == 0) throw runtime_error("Zero-byte file"); - size = std::min(length, 512 * 1024); + size = std::min(length, 512 * 1024); in.read(reinterpret_cast(image.get()), size); } else diff --git a/src/emucore/FSNode.hxx b/src/emucore/FSNode.hxx index da51fc508..80922cf37 100644 --- a/src/emucore/FSNode.hxx +++ b/src/emucore/FSNode.hxx @@ -238,7 +238,7 @@ class FilesystemNode * This method can throw exceptions, and should be used inside * a try-catch block. */ - uInt32 read(ByteBuffer& buffer) const; + size_t read(ByteBuffer& buffer) const; /** * The following methods are almost exactly the same as the various @@ -398,7 +398,7 @@ class AbstractFSNode * This method can throw exceptions, and should be used inside * a try-catch block. */ - virtual uInt32 read(ByteBuffer& buffer) const { return 0; } + virtual size_t read(ByteBuffer& buffer) const { return 0; } }; #endif diff --git a/src/emucore/MD5.cxx b/src/emucore/MD5.cxx index dbdf1c654..0746be907 100644 --- a/src/emucore/MD5.cxx +++ b/src/emucore/MD5.cxx @@ -307,20 +307,21 @@ static void Decode(uInt32* output, const uInt8* input, uInt32 len) } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -string hash(const ByteBuffer& buffer, uInt32 length) +string hash(const ByteBuffer& buffer, size_t length) { return hash(buffer.get(), length); } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -string hash(const uInt8* buffer, uInt32 length) +string hash(const uInt8* buffer, size_t length) { char hex[] = "0123456789abcdef"; MD5_CTX context; uInt8 md5[16]; + uInt32 len32 = static_cast(length); // Always use 32-bit for now MD5Init(&context); - MD5Update(&context, buffer, length); + MD5Update(&context, buffer, len32); MD5Final(md5, &context); string result; @@ -337,7 +338,7 @@ string hash(const uInt8* buffer, uInt32 length) string hash(const FilesystemNode& node) { ByteBuffer image; - uInt32 size = 0; + size_t size = 0; try { size = node.read(image); diff --git a/src/emucore/MD5.hxx b/src/emucore/MD5.hxx index 199ae6da4..48ab8967c 100644 --- a/src/emucore/MD5.hxx +++ b/src/emucore/MD5.hxx @@ -28,12 +28,17 @@ namespace MD5 { Get the MD5 Message-Digest of the specified message with the given length. The digest consists of 32 hexadecimal digits. + Note that currently, the length is truncated internally to + 32 bits, until the MD5 routines are rewritten for 64-bit. + Based on the size of data we currently use, this may never + actually happen. + @param buffer The message to compute the digest of @param length The length of the message @return The message-digest */ -string hash(const ByteBuffer& buffer, uInt32 length); -string hash(const uInt8* buffer, uInt32 length); +string hash(const ByteBuffer& buffer, size_t length); +string hash(const uInt8* buffer, size_t length); /** Get the MD5 Message-Digest of the file contained in 'node'. diff --git a/src/emucore/OSystem.cxx b/src/emucore/OSystem.cxx index b86ea4b43..70a575e7e 100644 --- a/src/emucore/OSystem.cxx +++ b/src/emucore/OSystem.cxx @@ -515,7 +515,7 @@ unique_ptr OSystem::openConsole(const FilesystemNode& romfile, string& // Open the cartridge image and read it in ByteBuffer image; - uInt32 size = 0; + size_t size = 0; if((image = openROM(romfile, md5, size)) != nullptr) { // Get a valid set of properties, including any entered on the commandline @@ -598,7 +598,7 @@ void OSystem::closeConsole() } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -ByteBuffer OSystem::openROM(const FilesystemNode& rom, string& md5, uInt32& size) +ByteBuffer OSystem::openROM(const FilesystemNode& rom, string& md5, size_t& size) { // This method has a documented side-effect: // It not only loads a ROM and creates an array with its contents, diff --git a/src/emucore/OSystem.hxx b/src/emucore/OSystem.hxx index fbf8a979b..e9ad20362 100644 --- a/src/emucore/OSystem.hxx +++ b/src/emucore/OSystem.hxx @@ -306,7 +306,7 @@ class OSystem @return Unique pointer to the array */ - ByteBuffer openROM(const FilesystemNode& rom, string& md5, uInt32& size); + ByteBuffer openROM(const FilesystemNode& rom, string& md5, size_t& size); /** Creates a new game console from the specified romfile, and correctly diff --git a/src/emucore/ProfilingRunner.cxx b/src/emucore/ProfilingRunner.cxx index f2bd97c0c..c50a4e538 100644 --- a/src/emucore/ProfilingRunner.cxx +++ b/src/emucore/ProfilingRunner.cxx @@ -102,7 +102,7 @@ bool ProfilingRunner::runOne(const ProfilingRun& run) } ByteBuffer image; - uInt32 size = imageFile.read(image); + size_t size = imageFile.read(image); if (size == 0) { cout << "ERROR: unable to read " << run.romFile << endl; return false; diff --git a/src/gui/GameInfoDialog.cxx b/src/gui/GameInfoDialog.cxx index ddd27bde2..7b2e213ea 100644 --- a/src/gui/GameInfoDialog.cxx +++ b/src/gui/GameInfoDialog.cxx @@ -399,7 +399,7 @@ void GameInfoDialog::loadEmulationProperties(const Properties& props) const FilesystemNode& node = FilesystemNode(instance().launcher().selectedRom()); ByteBuffer image; string md5 = props.get(PropType::Cart_MD5); - uInt32 size = 0; + size_t size = 0; // try to load the image for auto detection if(!instance().hasConsole() && @@ -635,7 +635,7 @@ void GameInfoDialog::updateControllerStates() bool autoDetect = false; ByteBuffer image; string md5 = myGameProperties.get(PropType::Cart_MD5); - uInt32 size = 0; + size_t size = 0; // try to load the image for auto detection if(!instance().hasConsole()) diff --git a/src/gui/RomInfoWidget.cxx b/src/gui/RomInfoWidget.cxx index 9cef9f0fe..c6914dc57 100644 --- a/src/gui/RomInfoWidget.cxx +++ b/src/gui/RomInfoWidget.cxx @@ -145,7 +145,7 @@ void RomInfoWidget::parseProperties(const FilesystemNode& node) { ByteBuffer image; string md5 = myProperties.get(PropType::Cart_MD5); - uInt32 size = 0; + size_t size = 0; if(node.exists() && !node.isDirectory() && (image = instance().openROM(node, md5, size)) != nullptr) diff --git a/src/gui/StellaSettingsDialog.cxx b/src/gui/StellaSettingsDialog.cxx index 391210349..17fb4f849 100644 --- a/src/gui/StellaSettingsDialog.cxx +++ b/src/gui/StellaSettingsDialog.cxx @@ -508,7 +508,7 @@ void StellaSettingsDialog::updateControllerStates() bool autoDetect = false; ByteBuffer image; string md5 = myGameProperties.get(PropType::Cart_MD5); - uInt32 size = 0; + size_t size = 0; // try to load the image for auto detection if(!instance().hasConsole())