From 0f45e0c52e5eddca9f17d94948f5cb0453b428d2 Mon Sep 17 00:00:00 2001 From: Misa Date: Mon, 15 May 2023 18:04:37 -0700 Subject: [PATCH] Print binary blob check fails and remove EOF check This prints all binary blob check fails. It's an error if the game rejects the header and will refuse to load it at all, and a warning if the game continues on. This also removes the EOF check (`offset + header->size > size`) as a fatal error. It will only print a warning now. If the last header goes past the end of file, it will be handled gracefully by PhysFS, which is the same case in VVVVVV 2.2. This actually fixes a regression from 2.3 where certain custom level tracks that were working perfectly fine in 2.2 (e.g. Summer Spooktacular's track 15) refused to play since 2.3. --- desktop_version/src/FileSystemUtils.cpp | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/desktop_version/src/FileSystemUtils.cpp b/desktop_version/src/FileSystemUtils.cpp index 2420643d..2254077b 100644 --- a/desktop_version/src/FileSystemUtils.cpp +++ b/desktop_version/src/FileSystemUtils.cpp @@ -898,19 +898,41 @@ bool FILESYSTEM_loadBinaryBlob(binaryBlob* blob, const char* filename) /* Name can be stupid, just needs to be terminated */ static const size_t last_char = sizeof(header->name) - 1; + if (header->name[last_char] != '\0') + { + vlog_warn( + "%s: Name of header %li is not null-terminated", + filename, i + ); + } header->name[last_char] = '\0'; if (header->valid & ~0x1 || !header->valid) { + if (header->valid & ~0x1) + { + vlog_error( + "%s: Header %li's 'valid' value is invalid", + filename, i + ); + } goto fail; /* Must be EXACTLY 1 or 0 */ } if (header->size < 1) { + vlog_error( + "%s: Header %li's size value is zero or negative", + filename, i + ); goto fail; /* Must be nonzero and positive */ } if (offset + header->size > size) { - goto fail; /* Bogus size value */ + /* Not an error, VVVVVV 2.2 and below handled it gracefully */ + vlog_warn( + "%s: Header %li's size value goes past end of file", + filename, i + ); } PHYSFS_seek(handle, offset);