snd_DvdSoundArchive OK

This commit is contained in:
robojumper
2025-05-25 22:26:16 +02:00
parent e16b0e7289
commit 5a7083ddba
4 changed files with 18 additions and 19 deletions
+9 -11
View File
@@ -56,8 +56,10 @@ bool DvdSoundArchive::Open(const char* pPath) {
char extRoot[FILE_PATH_MAX];
for (int i = std::strlen(pPath) - 1; i >= 0; i--) {
if (pPath[i] == '/' || pPath[i] == '\\') {
// @bug Long path can overflow extRoot buffer
if ((pPath[i] == '/' || pPath[i] == '\\')) {
if (i >= FILE_PATH_MAX + 1) {
return false;
}
std::strncpy(extRoot, pPath, i);
extRoot[i] = '\0';
@@ -70,8 +72,10 @@ bool DvdSoundArchive::Open(const char* pPath) {
}
void DvdSoundArchive::Close() {
DVDClose(&mFileInfo);
mOpen = false;
if (mOpen) {
DVDClose(&mFileInfo);
mOpen = false;
}
Shutdown();
}
@@ -115,7 +119,7 @@ bool DvdSoundArchive::LoadFileHeader() {
u8 headerArea[detail::SoundArchiveFile::HEADER_AREA_SIZE];
static const u32 headerAlignSize =
ut::RoundUp(sizeof(detail::SoundArchiveFile::Header), 32);
ROUND_UP(sizeof(detail::SoundArchiveFile::Header), 32);
void* pFile = ut::RoundUp<u8>(headerArea, 32);
@@ -173,9 +177,6 @@ bool DvdSoundArchive::LoadLabelStringData(void* pBuffer, u32 size) {
DvdSoundArchive::DvdFileStream::DvdFileStream(const DVDFileInfo* pFileInfo,
u32 offset, u32 size)
: DvdLockedFileStream(pFileInfo, false), mOffset(offset), mSize(size) {
if (mSize == 0) {
mSize = ut::DvdFileStream::GetSize();
}
ut::DvdFileStream::Seek(mOffset, SEEKORG_BEG);
}
@@ -183,9 +184,6 @@ DvdSoundArchive::DvdFileStream::DvdFileStream(const DVDFileInfo* pFileInfo,
DvdSoundArchive::DvdFileStream::DvdFileStream(s32 entrynum, u32 offset,
u32 size)
: DvdLockedFileStream(entrynum), mOffset(offset), mSize(size) {
if (mSize == 0) {
mSize = ut::DvdFileStream::GetSize();
}
ut::DvdFileStream::Seek(mOffset, SEEKORG_BEG);
}