vkd3d-shader/dxbc: Validate and skip the signature section header size.
1 unresolved thread
1 unresolved thread
Silences a very common warning.
Merge request reports
Activity
added 1 commit
- 55e9dec0 - vkd3d-shader/dxbc: Validate and skip the signature section header size.
1934 1934 read_dword(&ptr, &count); 1935 1935 TRACE("%u elements.\n", count); 1936 1936 1937 skip_dword_unknown(&ptr, 1); /* It seems to always be 0x00000008. */ 1937 read_dword(&ptr, &header_size); 1938 if (header_size & (sizeof(uint32_t) - 1)) 1939 { 1940 WARN("Header size %#x is not 32-bit aligned.\n", header_size); 1941 return VKD3D_ERROR_INVALID_ARGUMENT; 1942 } 1943 header_size /= sizeof(uint32_t); 1944 if (header_size < 2) 1945 { 1946 WARN("Invalid header size %u.\n", header_size); 1947 } changed this line in version 3 of the diff
@@ -1934,7 +1934,22 @@ static int shader_parse_signature(const struct vkd3d_shader_dxbc_section_desc *s read_dword(&ptr, &count); TRACE("%u elements.\n", count); - skip_dword_unknown(&ptr, 1); /* It seems to always be 0x00000008. */ + read_dword(&ptr, &header_size); + if (header_size & (sizeof(uint32_t) - 1)) + { + WARN("Header size %#x is not 32-bit aligned.\n", header_size); + return VKD3D_ERROR_INVALID_ARGUMENT; + } + header_size /= sizeof(uint32_t); + if (header_size < 2) + { + WARN("Invalid header size %u.\n", header_size); + } + else + { + for (header_size -= 2; header_size; --header_size) + skip_dword_unknown(&ptr, 1); + } if (!require_space(ptr - data, count, 6 * sizeof(uint32_t), section->data.size)) {
We should validate with require_space() that there is sufficient space left in the section to read the header.
When called from vkd3d_shader_parse_input_signature() in particular, ideally we'd use vkd3d_shader_error() to report parsing errors. This will require plumbing "message_context" from for_each_dxbc_section() through to "section_handler", and that's not an issue introduced in this patch, but since we're touching it...
added 12 commits
-
74a50ffd...98624f2e - 9 commits from branch
wine:master
- 83e39e26 - vkd3d-shader/dxbc: Pass a message context to for_each_dxbc_section().
- 3b5316be - vkd3d-shader/dxbc: Emit a shader error for an invalid signature data size.
- 9f6e6d3f - vkd3d-shader/dxbc: Validate and skip the signature section header size.
Toggle commit list-
74a50ffd...98624f2e - 9 commits from branch
Please register or sign in to reply