Skip to content
Snippets Groups Projects

vkd3d-shader/dxbc: Validate and skip the signature section header size.

Merged Conor McCarthy requested to merge cmccarthy/vkd3d:sig_header into master
1 unresolved thread

Silences a very common warning.

Merge request reports

Loading
Loading

Activity

Filter activity
  • Approvals
  • Assignees & reviewers
  • Comments (from bots)
  • Comments (from users)
  • Commits & branches
  • Edits
  • Labels
  • Lock status
  • Mentions
  • Merge request status
  • Tracking
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 }
  • @@ -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...

  • Conor McCarthy added 3 commits

    added 3 commits

    • 568d4c1d - vkd3d-shader/dxbc: Pass a message context to for_each_dxbc_section().
    • 11f8f589 - vkd3d-shader/dxbc: Emit a shader error for an invalid signature data size.
    • 74a50ffd - vkd3d-shader/dxbc: Validate and skip the signature section header size.

    Compare with previous version

  • Henri Verbeet approved this merge request

    approved this merge request

  • 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.

    Compare with previous version

  • Alexandre Julliard approved this merge request

    approved this merge request

  • Please register or sign in to reply
    Loading