mirror of
https://github.com/ValveSoftware/Proton.git
synced 2025-05-31 15:57:42 +03:00
vrclient: Validate exact size for InputSkeletalActionData_t.
CW-Bug-Id: #25461
This commit is contained in:
parent
32e146c3e5
commit
b8ebaf63de
@ -147,19 +147,19 @@ SIZED_STRUCTS = {
|
||||
"VROverlayView_t",
|
||||
}
|
||||
|
||||
STRUCTS_NEXT_IS_SIZE = [
|
||||
"VREvent_t",
|
||||
"VRControllerState001_t",
|
||||
"InputAnalogActionData_t",
|
||||
"InputDigitalActionData_t",
|
||||
"InputPoseActionData_t",
|
||||
"InputSkeletalActionData_t",
|
||||
"CameraVideoStreamFrameHeader_t",
|
||||
"Compositor_CumulativeStats",
|
||||
"VRActiveActionSet_t",
|
||||
"InputOriginInfo_t",
|
||||
"InputBindingInfo_t",
|
||||
]
|
||||
STRUCTS_NEXT_IS_SIZE = {
|
||||
"VREvent_t" : None,
|
||||
"VRControllerState001_t" : None,
|
||||
"InputAnalogActionData_t" : None,
|
||||
"InputDigitalActionData_t" : None,
|
||||
"InputPoseActionData_t" : None,
|
||||
"InputSkeletalActionData_t" : "/* VRInputError_WrongType */ 2",
|
||||
"CameraVideoStreamFrameHeader_t" : None,
|
||||
"Compositor_CumulativeStats" : None,
|
||||
"VRActiveActionSet_t" : None,
|
||||
"InputOriginInfo_t" : None,
|
||||
"InputBindingInfo_t" : None,
|
||||
}
|
||||
|
||||
STRUCTS_IS_INPUT_ARRAY = [
|
||||
"VRActiveActionSet_t",
|
||||
@ -265,7 +265,6 @@ MANUAL_METHODS = {
|
||||
OUTSTR_PARAMS = {
|
||||
}
|
||||
|
||||
|
||||
def is_manual_method(klass, method, abi):
|
||||
version = re.search(r'(\d+)$', klass.version)
|
||||
|
||||
@ -933,7 +932,7 @@ def handle_method_c(klass, method, winclassname, out):
|
||||
next_name, next_param = params[i + 1]
|
||||
if next_param and next_param.type.spelling == "uint32_t":
|
||||
out(f' {declspec(param.type.get_pointee(), f"w_{name}", "w_")};\n')
|
||||
param_sizes[name] = next_name
|
||||
param_sizes[name] = (next_name, STRUCTS_NEXT_IS_SIZE.get(strip_ns(real_type.spelling)))
|
||||
|
||||
out(f' struct {method.full_name}_params params =\n')
|
||||
out(u' {\n')
|
||||
@ -952,11 +951,18 @@ def handle_method_c(klass, method, winclassname, out):
|
||||
if 'eTextureType' in names:
|
||||
out(u' if (eTextureType == TextureType_DirectX) FIXME( "Not implemented Direct3D API!\\n" );\n')
|
||||
|
||||
for name, size in param_sizes.items():
|
||||
out(f' {size} = min( {size}, sizeof(w_{name}) );\n')
|
||||
for name, (size, size_check_error) in param_sizes.items():
|
||||
if size_check_error is not None:
|
||||
out(f' if ({size} != sizeof(w_{name}))\n')
|
||||
out(u' {\n')
|
||||
out(f' WARN("Unexpected size %u.\\n", {size});\n')
|
||||
out(f' return {size_check_error};\n')
|
||||
out(u' }\n')
|
||||
else:
|
||||
out(f' {size} = min( {size}, sizeof(w_{name}) );\n')
|
||||
out(f' if ({name}) memcpy( &w_{name}, {name}, {size} );\n')
|
||||
out(f' VRCLIENT_CALL( {method.full_name}, ¶ms );\n')
|
||||
for name, size in param_sizes.items():
|
||||
for name, (size, _) in param_sizes.items():
|
||||
out(f' if ({name}) memcpy( {name}, &w_{name}, {size} );\n')
|
||||
|
||||
if method.name in OUTSTR_PARAMS and OUTSTR_PARAMS[method.name] in names:
|
||||
|
@ -525,7 +525,11 @@ uint32_t __thiscall winIVRInput_IVRInput_004_GetSkeletalActionData(struct w_ifac
|
||||
.ulRestrictToDevice = ulRestrictToDevice,
|
||||
};
|
||||
TRACE("%p\n", _this);
|
||||
unActionDataSize = min( unActionDataSize, sizeof(w_pActionData) );
|
||||
if (unActionDataSize != sizeof(w_pActionData))
|
||||
{
|
||||
WARN("Unexpected size %u.\n", unActionDataSize);
|
||||
return /* VRInputError_WrongType */ 2;
|
||||
}
|
||||
if (pActionData) memcpy( &w_pActionData, pActionData, unActionDataSize );
|
||||
VRCLIENT_CALL( IVRInput_IVRInput_004_GetSkeletalActionData, ¶ms );
|
||||
if (pActionData) memcpy( pActionData, &w_pActionData, unActionDataSize );
|
||||
@ -919,7 +923,11 @@ uint32_t __thiscall winIVRInput_IVRInput_005_GetSkeletalActionData(struct w_ifac
|
||||
.unActionDataSize = unActionDataSize,
|
||||
};
|
||||
TRACE("%p\n", _this);
|
||||
unActionDataSize = min( unActionDataSize, sizeof(w_pActionData) );
|
||||
if (unActionDataSize != sizeof(w_pActionData))
|
||||
{
|
||||
WARN("Unexpected size %u.\n", unActionDataSize);
|
||||
return /* VRInputError_WrongType */ 2;
|
||||
}
|
||||
if (pActionData) memcpy( &w_pActionData, pActionData, unActionDataSize );
|
||||
VRCLIENT_CALL( IVRInput_IVRInput_005_GetSkeletalActionData, ¶ms );
|
||||
if (pActionData) memcpy( pActionData, &w_pActionData, unActionDataSize );
|
||||
@ -1441,7 +1449,11 @@ uint32_t __thiscall winIVRInput_IVRInput_006_GetSkeletalActionData(struct w_ifac
|
||||
.unActionDataSize = unActionDataSize,
|
||||
};
|
||||
TRACE("%p\n", _this);
|
||||
unActionDataSize = min( unActionDataSize, sizeof(w_pActionData) );
|
||||
if (unActionDataSize != sizeof(w_pActionData))
|
||||
{
|
||||
WARN("Unexpected size %u.\n", unActionDataSize);
|
||||
return /* VRInputError_WrongType */ 2;
|
||||
}
|
||||
if (pActionData) memcpy( &w_pActionData, pActionData, unActionDataSize );
|
||||
VRCLIENT_CALL( IVRInput_IVRInput_006_GetSkeletalActionData, ¶ms );
|
||||
if (pActionData) memcpy( pActionData, &w_pActionData, unActionDataSize );
|
||||
@ -1968,7 +1980,11 @@ uint32_t __thiscall winIVRInput_IVRInput_007_GetSkeletalActionData(struct w_ifac
|
||||
.unActionDataSize = unActionDataSize,
|
||||
};
|
||||
TRACE("%p\n", _this);
|
||||
unActionDataSize = min( unActionDataSize, sizeof(w_pActionData) );
|
||||
if (unActionDataSize != sizeof(w_pActionData))
|
||||
{
|
||||
WARN("Unexpected size %u.\n", unActionDataSize);
|
||||
return /* VRInputError_WrongType */ 2;
|
||||
}
|
||||
if (pActionData) memcpy( &w_pActionData, pActionData, unActionDataSize );
|
||||
VRCLIENT_CALL( IVRInput_IVRInput_007_GetSkeletalActionData, ¶ms );
|
||||
if (pActionData) memcpy( pActionData, &w_pActionData, unActionDataSize );
|
||||
@ -2534,7 +2550,11 @@ uint32_t __thiscall winIVRInput_IVRInput_010_GetSkeletalActionData(struct w_ifac
|
||||
.unActionDataSize = unActionDataSize,
|
||||
};
|
||||
TRACE("%p\n", _this);
|
||||
unActionDataSize = min( unActionDataSize, sizeof(w_pActionData) );
|
||||
if (unActionDataSize != sizeof(w_pActionData))
|
||||
{
|
||||
WARN("Unexpected size %u.\n", unActionDataSize);
|
||||
return /* VRInputError_WrongType */ 2;
|
||||
}
|
||||
if (pActionData) memcpy( &w_pActionData, pActionData, unActionDataSize );
|
||||
VRCLIENT_CALL( IVRInput_IVRInput_010_GetSkeletalActionData, ¶ms );
|
||||
if (pActionData) memcpy( pActionData, &w_pActionData, unActionDataSize );
|
||||
|
Loading…
x
Reference in New Issue
Block a user