mirror of
https://github.com/baldurk/renderdoc.git
synced 2026-08-24 07:26:34 +00:00
Fix overflow when clamping length of buffer data fetch
This commit is contained in:
@@ -351,7 +351,7 @@ void D3D11DebugManager::GetBufferData(ID3D11Buffer *buffer, uint64_t offset, uin
|
||||
return;
|
||||
}
|
||||
|
||||
if(len == 0)
|
||||
if(len == 0 || len > desc.ByteWidth)
|
||||
{
|
||||
len = desc.ByteWidth - offs;
|
||||
}
|
||||
|
||||
@@ -819,7 +819,7 @@ void D3D12DebugManager::GetBufferData(ID3D12Resource *buffer, uint64_t offset, u
|
||||
return;
|
||||
}
|
||||
|
||||
if(length == 0)
|
||||
if(length == 0 || length > desc.Width)
|
||||
{
|
||||
length = desc.Width - offset;
|
||||
}
|
||||
|
||||
@@ -323,27 +323,23 @@ void GLReplay::GetBufferData(ResourceId buff, uint64_t offset, uint64_t len, byt
|
||||
|
||||
uint64_t bufsize = buf.size;
|
||||
|
||||
if(len > 0 && offset + len > bufsize)
|
||||
if(offset >= bufsize)
|
||||
{
|
||||
RDCWARN("Attempting to read off the end of the buffer (%llu %llu). Will be clamped (%llu)",
|
||||
offset, len, bufsize);
|
||||
|
||||
if(offset < bufsize)
|
||||
len = ~0ULL; // min below will clamp to max size
|
||||
else
|
||||
return; // offset past buffer size, return empty array
|
||||
// can't read past the end of the buffer, return empty
|
||||
return;
|
||||
}
|
||||
else if(len == 0)
|
||||
|
||||
if(len == 0 || len > bufsize)
|
||||
{
|
||||
len = bufsize;
|
||||
}
|
||||
|
||||
// need to ensure len+offset doesn't overrun buffer or the glGetBufferSubData call
|
||||
// will fail.
|
||||
len = RDCMIN(len, bufsize - offset);
|
||||
|
||||
if(len == 0)
|
||||
return;
|
||||
if(offset + len > bufsize)
|
||||
{
|
||||
RDCWARN("Attempting to read off the end of the buffer (%llu %llu). Will be clamped (%llu)",
|
||||
offset, len, bufsize);
|
||||
len = RDCMIN(len, bufsize - offset);
|
||||
}
|
||||
|
||||
ret.resize((size_t)len);
|
||||
|
||||
|
||||
@@ -1573,7 +1573,7 @@ void VulkanDebugManager::GetBufferData(ResourceId buff, uint64_t offset, uint64_
|
||||
return;
|
||||
}
|
||||
|
||||
if(len == 0)
|
||||
if(len == 0 || len > bufsize)
|
||||
{
|
||||
len = bufsize - offset;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user