mirror of
https://github.com/storytold/harfbuzz.git
synced 2026-11-28 00:59:16 +01:00
[bitmap] Clamp scaled glyph extents
Bitmap strike scaling converts attacker-controlled image dimensions and offsets to glyph positions through unchecked float and mixed-sign arithmetic. Widen the sbix coordinate sum and clamp scaled sbix and CBDT extents. This is part of the complete position-overflow fix for issue #6151. Testing: meson test -C build --print-errorlogs Assisted-by: Codex <codex@openai.com>
This commit is contained in:
1 parent
f65eab255c
commit
0855a58fdf
2 files changed
+11
-11
No files matched your search
@@ -885,10 +885,10 @@ struct CBDT
|
||||
{
|
||||
float x_scale = upem / (float) strike.ppemX;
|
||||
float y_scale = upem / (float) strike.ppemY;
|
||||
extents->x_bearing = roundf (extents->x_bearing * x_scale);
|
||||
extents->y_bearing = roundf (extents->y_bearing * y_scale);
|
||||
extents->width = roundf (extents->width * x_scale);
|
||||
extents->height = roundf (extents->height * y_scale);
|
||||
extents->x_bearing = hb_clamp_to<hb_position_t> (roundf (extents->x_bearing * x_scale));
|
||||
extents->y_bearing = hb_clamp_to<hb_position_t> (roundf (extents->y_bearing * y_scale));
|
||||
extents->width = hb_clamp_to<hb_position_t> (roundf (extents->width * x_scale));
|
||||
extents->height = hb_clamp_to<hb_position_t> (roundf (extents->height * y_scale));
|
||||
}
|
||||
|
||||
return true;
|
||||
|
||||
@@ -337,18 +337,18 @@ struct sbix
|
||||
}
|
||||
|
||||
extents->x_bearing = x_offset;
|
||||
extents->y_bearing = png.IHDR.height + y_offset;
|
||||
extents->width = png.IHDR.width;
|
||||
extents->height = -1 * png.IHDR.height;
|
||||
extents->y_bearing = hb_clamp_to<hb_position_t> ((int64_t) (unsigned int) png.IHDR.height + y_offset);
|
||||
extents->width = (hb_position_t) (unsigned int) png.IHDR.width;
|
||||
extents->height = -(hb_position_t) (unsigned int) png.IHDR.height;
|
||||
|
||||
/* Convert to font units. */
|
||||
if (strike_ppem && scale)
|
||||
{
|
||||
float scale = font->face->get_upem () / (float) strike_ppem;
|
||||
extents->x_bearing = roundf (extents->x_bearing * scale);
|
||||
extents->y_bearing = roundf (extents->y_bearing * scale);
|
||||
extents->width = roundf (extents->width * scale);
|
||||
extents->height = roundf (extents->height * scale);
|
||||
extents->x_bearing = hb_clamp_to<hb_position_t> (roundf (extents->x_bearing * scale));
|
||||
extents->y_bearing = hb_clamp_to<hb_position_t> (roundf (extents->y_bearing * scale));
|
||||
extents->width = hb_clamp_to<hb_position_t> (roundf (extents->width * scale));
|
||||
extents->height = hb_clamp_to<hb_position_t> (roundf (extents->height * scale));
|
||||
}
|
||||
|
||||
if (scale)
|
||||
|
||||
Reference in new issue
Block a user