36typedef enum : uint8_t {
55typedef enum : uint32_t {
72typedef enum : uint8_t {
86typedef enum : uint8_t {
113 return (uint16_t)(((uint32_t)p[0] <<
k_sfnt_shift_8) | (uint32_t)p[1]);
189 const uint32_t sub_tables =
193 return sub_end <= buf_len;
206 if (data ==
nullptr) {
210 const uint64_t buf_len = (uint64_t)len;
211 const uint64_t start = (uint64_t)fontstart;
219 const uint32_t num_tables =
226 if (dir_end > buf_len) {
237 for (uint32_t i = 0U; i < num_tables; ++i) {
241 const uint64_t t_off =
243 const uint64_t t_len =
245 if ((t_off + t_len) > buf_len) {
Annotation-attribute framework macros for ra8-firmware.
#define RA8_INTERNAL
Marker that a function is intended to be static (file-local).
sfnt_internal_layout_t
Byte offsets stbtt_InitFont() reads inside cmap / head / maxp.
@ k_maxp_num_glyphs_end
maxp: InitFont reads uint16 at maxp+4 -> +6.
@ k_head_loc_format_end
head: InitFont reads uint16 at head+50 -> +52.
@ k_cmap_header_bytes
cmap: version(2) + numTables(2) before records.
@ k_cmap_num_tables_off
cmap: uint16 numTables offset in the table.
@ k_cmap_record_bytes
cmap: one encoding-record size, bytes.
bool ra8_stbtt_sfnt_dir_in_bounds(const uint8_t *data, size_t len, uint32_t fontstart)
Verify that a font's sfnt table directory lies within its buffer.
static uint32_t internal_rd_be_u32(const uint8_t *p)
Read a big-endian uint32 from a four-byte, in-bounds location.
sfnt_shift_t
Bit-shift distances for assembling big-endian scalars.
@ k_sfnt_shift_16
Two-byte shift.
@ k_sfnt_shift_24
Three-byte shift.
@ k_sfnt_shift_8
One-byte shift.
sfnt_layout_t
Byte offsets and sizes of the sfnt offset table and table records.
@ k_sfnt_table_record_bytes
Size of one table directory record, bytes.
@ k_sfnt_record_offset_off
uint32 table-offset field offset in a record.
@ k_sfnt_offset_table_bytes
sfnt offset table (header) size, bytes.
@ k_sfnt_record_length_off
uint32 table-length field offset in a record.
@ k_sfnt_record_tag_off
4-byte table tag offset in a record.
@ k_sfnt_num_tables_off
uint16 numTables offset in the offset table.
static bool internal_table_internal_in_bounds(const uint8_t *data, uint64_t buf_len, uint32_t tag, uint64_t t_off)
Prove the reads stbtt_InitFont() makes inside a known table stay in-bounds, given the table's already...
static uint16_t internal_rd_be_u16(const uint8_t *p)
Read a big-endian uint16 from a two-byte, in-bounds location.
sfnt_tag_t
Big-endian sfnt table tags whose internal layout stbtt_InitFont() reads with an attacker-controlled c...
@ k_sfnt_tag_cmap
'cmap' – character-to-glyph mapping.
@ k_sfnt_tag_maxp
'maxp' – maximum profile (numGlyphs).
@ k_sfnt_tag_head
'head' – font header (indexToLocFormat).
sfnt (TrueType/OpenType) table-directory bounds guard for stb_truetype.