Skip to content

[C++][Gandiva] Out-of-bounds read in mask functions from wrong utf8proc_iterate length #50707

Description

@Arawoof06

The Gandiva mask stubs walk a utf8 string with utf8proc_iterate, but pass the total data_len as the remaining-byte count instead of data_len - bytes_read even though the pointer has already advanced:

  • gdv_mask_first_n_utf8_int32
  • gdv_mask_last_n_utf8_int32
  • mask_utf8_utf8_utf8_utf8

utf8proc_iterate(str, strlen, ...) reads up to strlen bytes from str. With str = data + bytes_read and strlen = data_len, a truncated trailing multi-byte glyph (for example a lead byte 0xF0 as the final byte of an exactly-sized value buffer) makes utf8proc read continuation bytes past data + data_len.

This is reachable from mask() / mask_first_n() / mask_last_n() on untrusted string data whose value buffer is exactly sized. Passing the true remaining length lets utf8proc report the truncated glyph instead of over-reading.

Component(s)

C++, Gandiva

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions