Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WbfsBlob: Don't enter an infinite loop when reading beyond end of disc #2712

Merged
merged 1 commit into from
Jul 12, 2015
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
WbfsBlob: Don't enter an infinite loop when reading beyond end of disc
read_size remained 0 when the "Read beyond end of disc" error occurs,
which made the while (nbytes) loop never end. As a fix, SeekToCluster
now explicitly sets available to 0 when the error occurs, and Read
checks for it.
  • Loading branch information
JosJuice committed Jul 6, 2015
commit 9018b546c71932a46a85222a3de7a989184361ec
6 changes: 5 additions & 1 deletion Source/Core/DiscIO/WbfsBlob.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -115,8 +115,10 @@ bool WbfsFileReader::Read(u64 offset, u64 nbytes, u8* out_ptr)
{
while (nbytes)
{
u64 read_size = 0;
u64 read_size;
File::IOFile& data_file = SeekToCluster(offset, &read_size);
if (read_size == 0)
return false;
read_size = (read_size > nbytes) ? nbytes : read_size;

if (!data_file.ReadBytes(out_ptr, read_size))
Expand Down Expand Up @@ -160,6 +162,8 @@ File::IOFile& WbfsFileReader::SeekToCluster(u64 offset, u64* available)
}

PanicAlert("Read beyond end of disc");
if (available)
*available = 0;
m_files[0]->file.Seek(0, SEEK_SET);
return m_files[0]->file;
}
Expand Down