mirror of
https://github.com/gnif/LookingGlass.git
synced 2026-08-24 16:11:31 +00:00
[host] d12: stop invalid pointer shape copies
This commit is contained in:
@@ -78,6 +78,7 @@ typedef struct DDInstance
|
||||
|
||||
void * shapeBuffer;
|
||||
unsigned shapeBufferSize;
|
||||
unsigned shapeSize;
|
||||
}
|
||||
DDInstance;
|
||||
|
||||
@@ -424,7 +425,7 @@ retry:
|
||||
&pointer, frameInfo.PointerShapeBufferSize, &postPointer);
|
||||
|
||||
if (postPointer)
|
||||
d12_updatePointer(&pointer, this->shapeBuffer, this->shapeBufferSize);
|
||||
d12_updatePointer(&pointer, this->shapeBuffer, this->shapeSize);
|
||||
|
||||
// if this was not a frame update, go back and try again
|
||||
if (frameInfo.LastPresentTime.QuadPart == 0)
|
||||
@@ -714,6 +715,13 @@ retry:
|
||||
return;
|
||||
}
|
||||
|
||||
if (!s || s > this->shapeBufferSize || !info.Height || !info.Pitch ||
|
||||
(size_t)info.Height > (size_t)s / info.Pitch)
|
||||
{
|
||||
DEBUG_ERROR("Desktop duplication returned an invalid pointer shape");
|
||||
return;
|
||||
}
|
||||
|
||||
switch(info.Type)
|
||||
{
|
||||
case DXGI_OUTDUPL_POINTER_SHAPE_TYPE_COLOR:
|
||||
@@ -739,6 +747,7 @@ retry:
|
||||
pointer->pitch = info.Pitch;
|
||||
pointer->hx = info.HotSpot.x;
|
||||
pointer->hy = info.HotSpot.y;
|
||||
this->shapeSize = s;
|
||||
|
||||
*changed = true;
|
||||
}
|
||||
|
||||
@@ -1613,9 +1613,13 @@ void d12_updatePointer(CapturePointer * pointer, void * shape, size_t shapeSize)
|
||||
DEBUG_ERROR("Failed to obtain a buffer for the pointer shape");
|
||||
pointer->shapeUpdate = false;
|
||||
}
|
||||
|
||||
size_t copySize = min(dstSize, shapeSize);
|
||||
memcpy(dst, shape, copySize);
|
||||
else if (!shape || !shapeSize || shapeSize > dstSize)
|
||||
{
|
||||
DEBUG_ERROR("Pointer shape does not fit in the destination buffer");
|
||||
pointer->shapeUpdate = false;
|
||||
}
|
||||
else
|
||||
memcpy(dst, shape, shapeSize);
|
||||
}
|
||||
|
||||
this->postPointerBufferFn(pointer);
|
||||
|
||||
Reference in New Issue
Block a user