mirror of https://github.com/AxioDL/metaforce.git
CTexture bounds validation
This commit is contained in:
parent
ce3014b313
commit
2dbb06f8b1
|
@ -35,8 +35,8 @@ class CTexture
|
|||
void BuildRGB5A3FromGCN(CInputStream& in);
|
||||
void BuildRGBA8FromGCN(CInputStream& in);
|
||||
void BuildDXT1FromGCN(CInputStream& in);
|
||||
void BuildRGBA8(const void* data);
|
||||
void BuildC8(const void* data);
|
||||
void BuildRGBA8(const void* data, size_t length);
|
||||
void BuildC8(const void* data, size_t length);
|
||||
|
||||
public:
|
||||
CTexture(std::unique_ptr<u8[]>&& in, u32 length);
|
||||
|
|
|
@ -648,21 +648,28 @@ void CTexture::BuildDXT1FromGCN(CInputStream& in)
|
|||
});
|
||||
}
|
||||
|
||||
void CTexture::BuildRGBA8(const void* data)
|
||||
void CTexture::BuildRGBA8(const void* data, size_t length)
|
||||
{
|
||||
size_t texelCount = ComputeMippedTexelCount();
|
||||
size_t expectedSize = texelCount * 4;
|
||||
if (expectedSize > length)
|
||||
Log.report(logvisor::Fatal, "insufficient TXTR length (%" PRISize "/%" PRISize ")",
|
||||
length, expectedSize);
|
||||
|
||||
m_booToken = CGraphics::CommitResources([&](boo::IGraphicsDataFactory::Context& ctx) -> bool
|
||||
{
|
||||
m_booTex = ctx.newStaticTexture(x4_w, x6_h, x8_mips, boo::TextureFormat::RGBA8,
|
||||
data, texelCount * 4);
|
||||
data, expectedSize);
|
||||
return true;
|
||||
});
|
||||
}
|
||||
|
||||
void CTexture::BuildC8(const void* data)
|
||||
void CTexture::BuildC8(const void* data, size_t length)
|
||||
{
|
||||
size_t texelCount = ComputeMippedTexelCount();
|
||||
if (texelCount > length)
|
||||
Log.report(logvisor::Fatal, "insufficient TXTR length (%" PRISize "/%" PRISize ")",
|
||||
length, texelCount);
|
||||
|
||||
m_booToken = CGraphics::CommitResources([&](boo::IGraphicsDataFactory::Context& ctx) -> bool
|
||||
{
|
||||
|
@ -722,10 +729,10 @@ CTexture::CTexture(std::unique_ptr<u8[]>&& in, u32 length)
|
|||
BuildDXT1FromGCN(r);
|
||||
break;
|
||||
case ETexelFormat::RGBA8PC:
|
||||
BuildRGBA8(owned.get() + 12);
|
||||
BuildRGBA8(owned.get() + 12, length - 12);
|
||||
break;
|
||||
case ETexelFormat::C8PC:
|
||||
BuildC8(owned.get() + 12);
|
||||
BuildC8(owned.get() + 12, length - 12);
|
||||
break;
|
||||
default:
|
||||
Log.report(logvisor::Fatal, "invalid texture type %d for boo", int(x0_fmt));
|
||||
|
|
2
hecl
2
hecl
|
@ -1 +1 @@
|
|||
Subproject commit 172d1de275d05f1fc8d69dac0c193d7c8bcc78cd
|
||||
Subproject commit 42679f2a3ae651a7c070688969a8a8430791256e
|
Loading…
Reference in New Issue