Commit Graph

93 Commits

Author SHA1 Message Date
Werner Lemberg 695d606ae5 Whitespace. 2022-04-01 08:50:33 +02:00
Alexei Podtelezhnikov 0d2b4952a3 [psaux, type1, type42] Avoid annecessary zeroing.
* src/psaux/psobjs.c (ps_table_new): Use FT_QNEW_ARRAY.
* src/type1/t1load.c (parse_encoding): Ditto.
* src/type42/t42parse.c (t42_parse_encoding): Ditto.
2022-01-20 14:47:01 -05:00
Ben Wagner e838c37c2c [type42] Track how much type42 ttf data is available.
Currently `T42_Open_Face` eagerly allocates 12 bytes for the ttf header
data which it expects `t42_parse_sfnts` to fill out from /sfnts data.
However, there is no guarantee that `t42_parse_sfnts` will actually be
called while parsing the type42 data as the /sfnts array may be missing
or very short. This is also confusing behavior as it means
`T42_Open_Face` is tightly coupled to the implementation of the very
distant `t42_parse_sfnts` code which requires at least 12 bytes to
already be reserved in `face->ttf_data`.

`t42_parse_sfnts` itself eagerly updates `face->ttf_size` to track how
much space is reserved for ttf data instead of traking how much data has
actually been written into `face->ttf_data`. It will also act strangely
in the presense of multiple /sfnts arrays.

* src/type42/t42objs.c (T42_Open_Face): ensure `ttf_data` is initialized
to NULL. Free `ttf_data` on error.

* src/type42/t42parse.c (t42_parse_sfnts): delay setting `ttf_size` and
set it to the actual number of bytes read. Ensure `ttf_data` is freed
if there are multiple /sfnts arrays or there are any errors.
2022-01-11 14:58:18 -05:00
Werner Lemberg d0cfb4e1b2 Update all copyright notices. 2022-01-11 10:54:10 +01:00
Werner Lemberg 7a493e3a40 [sfnt, type42] Correct previous commit.
Really fix https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=42773.

* src/sfnt/ttload.c (check_table_dir): Revert change.

* src/type42/t42.parse.c (t42_parse_sfnts): Don't use `FT_QREALLOC` but
`FT_REALLOC` for setting up `ttf_data` to avoid uninitialized memory access
while handling malformed TrueType fonts later on.
2022-01-08 10:28:19 +01:00
Alexei Podtelezhnikov 2468e59af1 [type42] Avoid some memory zeroing.
* src/type42/t42objs.c (T42_Open_Face): Tweak allocation macro.
* src/type42/t42parse.c (t42_parse_sfnts): Ditto.
2021-05-20 22:20:36 -04:00
Alexei Podtelezhnikov ec9e5114b1 [cff,type1,type42] s/FT_ALLOC/FT_QALLOC/ for initialized buffers.
* src/cff/cffload.c (cff_index_get_pointers, cff_index_get_name):
Do not zero out the buffer.
* src/cff/cffdrivr.c (cff_ps_get_font_info): Ditto.
* src/type1/t1load.c (parse_subrs, parse_charstrings,
parse_blend_axis_types): Ditto.
* src/type1/t1parse.c (T1_New_Parser, T1_Get_Private_Dict): Ditto.
* src/type42/t42parse.c (t42_parser_init): Ditto.
2021-04-23 14:03:03 -04:00
Werner Lemberg b6e8a71266 Update all copyright notices. 2021-01-17 07:18:48 +01:00
Werner Lemberg 7691588098 * src/type42/t42parse.c: Fix `-Wformat` warnings. 2020-12-04 16:19:42 +01:00
Werner Lemberg 32b14552d6 * src/type42/t42parse.c (t42_parse_sfnts): More tracing messages. 2020-11-09 21:00:45 +01:00
Priyesh Kumar 53be1753de Fix `-Wformat' compiler warnings.
* src/*: Fix format specifiers.

* builds/unix/ftsystem.c (FT_Stream_Open): Ditto.
2020-07-28 07:33:40 +02:00
David Turner e13391333f Make macros for header file names optional.
We no longer have to take care of the 8.3 file name limit; this
allows us (a) to introduce longer, meaningful file names, and (b) to
avoid macro names in `#include' lines altogether since some
compilers (most notably Visual C++) doesn't support this properly.

*/*: Replace

   #include FOO_H

with

   #include <freetype/foo.h>

or something similar.  Also update the documentation.
2020-06-08 13:31:55 +02:00
Werner Lemberg e5038be704 Update all copyright notices. 2020-01-19 17:05:19 +01:00
Alexei Podtelezhnikov 78c02bc110 [type1,type42] Use `const' for string literals.
* include/freetype/internal/psaux.h (PS_Table_FuncsRec): Updated.
* include/freetype/internal/t1types.h (T1_EncodingRec): Updated.
* src/psaux/psobjs.[ch] (ps_table_add): Updated.
* src/type1/t1load.c (T1_Open_Face, parse_encoding): Updated.
* src/type42/t42objs.c (T42_Open_Face): Updated.
* src/type42/t42parse.c (t42_parse_encoding): Updated.

* src/cff/cffobjs.c (cff_face_init): Minor.
2019-06-10 23:09:49 -04:00
Werner Lemberg 7b84104720 Various clang 8.0 static analyzer fixes.
Reported by Sender Ghost <lightside@gmx.com>.

* src/autofit/afcjk.c (af_cjk_hints_compute_edges): Catch a corner
case where `edge->first' could be NULL.

* src/pfr/pfrobjs.c (pfr_slot_load): Remove unnecessary test of
`size'.

* src/raster/ftraster.c (Draw_Sweep): Catch a corner case where
`draw_right' might be NULL.

* src/sfnt/ttmtx.c (tt_face_get_metrics): Fix limit test for
`aadvance'.
Ensure `abearing' always hold a meaningful result.

* src/truetype/ttgload.c (load_truetype_glyph): Ensure `subglyph' is
not NULL before accessing it.
* src/truetype/ttgxvar.c (TT_Set_Named_Instance): Remove unnecessary
test of `namedstyle'.

* src/type42/t42parse.c (t42_parser_done): Ensure
`parser->root.funcs.done' is not NULL before accessing it.
2019-05-04 08:13:22 +02:00
Werner Lemberg 7585997024 Update all copyright notices. 2019-02-23 10:07:09 +01:00
Werner Lemberg f686ad46a3 Update copyright years. 2019-01-22 20:31:44 +01:00
Werner Lemberg a0dd16fb3d Don't use `trace_' prefix for FT_COMPONENT arguments.
* include/freetype/internal/ftdebug.h (FT_TRACE_COMP,
FT_TRACE_COMP_): New auxiliary macros to add `trace_' prefix.
(FT_TRACE): Use `FT_TRACE_COMP'.

*/* (FT_COMPONENT): Updated.
2018-08-15 18:13:17 +02:00
Werner Lemberg 50486df1e6 * src/type42/t42parse.c (t42_parse_sfnts): One more format check.
Reported as

  https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=9832
2018-08-13 08:46:53 +02:00
Werner Lemberg cc3333902b New base function `FT_Matrix_Check' (#54019).
* src/base/ftcalc.c (FT_Matrix_Check): New base function to properly
reject degenerate font matrices.

* include/freetype/internal/ftcalc.h: Updated.

* src/cff/cffparse.c (cff_parse_font_matrix), src/cid/cidload.c
(cid_parse_font_matrix), src/type1/t1load.c (t1_parse_font_matrix),
src/type42/t42parse.c (t42_parse_font_matrix): Use
`FT_Matrix_Check'.
2018-06-24 06:26:09 +02:00
Werner Lemberg 9ac9060df0 [GSoC] src/*.*: Convert block comments to `light' style.
This monster commit was created by applying Nikhil's scripts
`docconverter.py' and `markify.py' to all C header and source files,
followed up by minor manual clean-up.

No change in functionality, of course.

I used commit f7419907bc6044b9b7057f9789866426c804ba82 from
https://github.com/nikramakrishnan/freetype-docs.git.
2018-06-03 09:08:41 +02:00
Werner Lemberg 0a0c22569d Update copyright year. 2018-01-02 09:33:57 +01:00
Werner Lemberg 563ae78022 Update copyright year. 2017-01-04 20:16:34 +01:00
Werner Lemberg 37c72f66a5 Minor formatting. 2016-12-25 22:55:25 +01:00
Werner Lemberg 2ecf89b481 */*: s/FT_MEM_ZERO/FT_ZERO/ where appropriate. 2016-09-28 19:06:21 +02:00
Werner Lemberg d28eac249a [type42] Support `CharStrings' entry format as created by LilyPond.
* src/type42/t42parse.c (t42_parse_charstrings): Handle entries
having the format

  (foo) cvn 12345 def
2016-05-30 00:23:59 +02:00
Werner Lemberg 9adeab6452 Update copyright year. 2016-01-13 11:54:10 +01:00
Werner Lemberg e93d326c8b [sfnt, type42] Fix clang compiler warnings.
* src/sfnt/sfobjs.c (sfnt_init_face): Initialize `offset'.

* src/type42/t42parse.c (t42_parse_sfnts): Use proper cast.
2015-10-22 10:17:20 +02:00
Werner Lemberg 87fefc594e [type42] Fix heap buffer overflow (#46269).
* src/type42/t42parse.c (t42_parse_sfnts): Fix off-by-one error in
bounds checking.
2015-10-21 20:29:12 +02:00
Werner Lemberg 649ca5562d [type42] Better check invalid `sfnts' array data (#46255).
* src/type42/t42parse.c (t42_parse_sfnts): Table lengths must be
checked individually against available data size.
2015-10-21 07:01:45 +02:00
Werner Lemberg 06c2d3324e [type42] Protect against invalid number of glyphs (#46159).
* src/type42/t42parse.c (t42_parse_charstrings): Check number of
`CharStrings' dictionary entries against size of data stream.
2015-10-08 21:31:57 +02:00
Werner Lemberg f28c95c4a4 [type42] Fix memory leak (#45989).
* src/type42/t42parse.c (t42_parse_charstrings): Allow only a single
`CharStrings' array.
2015-09-17 19:30:26 +02:00
Werner Lemberg 19cb1127d4 [type1, type42] Fix memory leaks (#45966).
* src/type1/t1load.c (parse_blend_axis_types): Handle multiple axis
names.
(parse_blend_design_map): Allow only a single design map.
(parse_encoding): Handle multiple encoding vectors.

* src/type42/t42parse.c (t42_parse_encoding): Handle multiple
encoding vectors.
2015-09-15 08:52:36 +02:00
Werner Lemberg 581c7e2a51 [type1, type42] Check encoding array size (#45961).
* src/type1/t1load.c (parse_encoding), src/type42/t42parse.c
(t42_parse_encoding): Do it.
2015-09-15 06:49:06 +02:00
Werner Lemberg 23423bc6f9 [type42] Fix endless loop (#45920).
* src/type42/t42parse.c (t42_parse_encoding): Synchronize with
type1's `parse_encoding'.
2015-09-11 08:28:27 +02:00
Alexei Podtelezhnikov a37da21a49 [type1,cid,type42] Minor improvements.
* src/type1/t1load.c (t1_parse_font_matrix): Scale units per EM only
when necessary. Refresh comments.
* src/cid/cidload.c (cid_parse_font_matrix): Ditto.
* src/type42/t42parse.c (t42_parse_font_matrix): Refresh comments.
2015-08-10 23:05:02 -04:00
Werner Lemberg e5f4469359 [type42] Minor clean-up.
* src/type42/t42parse.c (t42_parse_font_matrix): Remove unused
variable.
2015-08-08 07:45:03 +02:00
Alexei Podtelezhnikov fd70512eee [type42] Parse FontMatrix according to specifications.
* src/type42/t42parse.c (t42_parse_font_matrix): Type 42 FontMatrix
does not need scaling by 1000. Units_per_EM are taken from the
embedded TrueType.
2015-08-06 21:49:08 -04:00
Alexei Podtelezhnikov eabc8d72e0 [psaux,psnames,type1,type42] NULL. 2015-04-12 23:16:48 -04:00
Werner Lemberg 851e815127 Various compiler warning fixes for `make multi'.
* src/autofit/afcjk.c (af_cjk_hints_compute_blue_edges),
src/autofit/aflatin.c (af_latin_hint_compute_blue_edges,
af_latin_hint_edges), src/autofit/aflatin2.c
(af_latin2_hints_compute_blue_edges, af_latin2_hint_edges): Declare
as `static'.

* src/cache/ftccmap.c (FTC_CMAP_QUERY_HASH, FTC_CMAP_NODE_HASH):
Removed.  Unused.
* src/cache/ftcimage.c: Include FT_INTERNAL_OBJECTS_H.
* src/cache/ftcmanag.c (FTC_LRU_GET_MANAGER): Removed.  Unused.

* src/cff/cf2intrp.c: Include `cf2intrp.h'.
* src/cff/cffdrivr.c (PAIR_TAG): Removed.  Unused.

* src/gzip/ftgzip.c (NO_DUMMY_DECL): Removed.  Unused.

* src/psaux/afmparse.c (afm_parser_read_int): Declare as `static'.

* src/pshinter/pshalgo.c (STRONGER, PSH_ZONE_MIN, PSH_ZONE_MAX):
Removed.  Unused.

* src/raster/ftraster.c (Render_Glyph): Declare as `static'.

* src/sfnt/ttpost.c (load_format_20): Fix signedness warning.

* src/truetype/ttdriver.c (PAIR_TAG): Removed.  Unused.
* src/truetype/ttsubpix.c (is_member_of_family_class,
is_member_of_style_class): Declare as `static'.

* src/type1/t1gload.c (T1_Parse_Glyph_And_Get_Char_String): Declare
as `static'.
* src/type1/t1load.c (mm_axis_unmap, mm_weights_unmap): Declare as
`static'.
(T1_FIELD_COUNT): Removed.  Unused.
* src/type1/t1parse.h (T1_Done_Table): Removed.  Unused.

* src/type42/t42parse.c (T1_Done_Table): Removed.  Unused.
2015-03-01 19:27:09 +01:00
Werner Lemberg 7b6b417c97 [type42] Signedness fixes.
* src/type42/t42parse.c, src/type42/t42parse.h,
src/type42/t42types.h: Apply.
2015-02-21 10:39:34 +01:00
Werner Lemberg 6bd7d28fc7 Don't use `FT_PtrDist' for lengths.
Use FT_UInt instead.

* include/internal/psaux.h (PS_Table_FuncsRec, PS_TableRec,
T1_DecoderRec): Do it.

* include/internal/t1types.h (T1_FontRec): Ditto.

* src/cid/cidload.c (cid_parse_dict): Updated.
* src/pfr/pfrload.c (pfr_extra_item_load_font_id): Ditto.
* src/psaux/psobjs.c (ps_table_add), src/psaux/psobjs.h: Ditto.
* src/type1/t1load.c (parse_blend_axis_types, parse_encoding,
parse_chharstrings, parse_dict): Ditto.
* src/type42/t42parse.c (t42_parse_encoding, t42_parse_charstrings,
t42_parse_dict): Ditto.
2015-02-18 09:22:06 +01:00
Werner Lemberg f57fc59e01 Run `src/tools/update-copyright'. 2015-01-17 20:41:43 +01:00
Werner Lemberg 812ed34189 * src/type42/t42parse.c (t42_parse_sfnts): Reject invalid TTF size. 2014-12-11 14:07:29 +01:00
Werner Lemberg b94381134e * src/type42/t42parse.c (t42_parse_sfnts): Check `string_size'.
Problem reported by Dennis Felsing <dennis@felsin9.de>.
2014-12-11 13:33:14 +01:00
Werner Lemberg b24e8ba28a [Savannah bug #43682] Add/remove `void' casts to some functions.
We use a cast to indicate that we intentionally ignore a function's
return value.  However, this doesn't apply to API functions where
errors can only happen for trivially invalid input.

* src/base/ftstroke.c (FT_Glyph_Stroke, FT_Glyph_StrokeBorder),
src/base/ftsynth.c (FT_GlyphSlot_Embolden), src/cff/cffgload.c
(cff_slot_load), src/pfr/pfrdrivr.c (pfr_get_kerning),
src/type1/t1load.c (parse_encoding), src/type42/t42parse.c
(t42_parse_encoding): Do it.
2014-11-25 08:30:49 +01:00
Werner Lemberg 73be9f9ab6 [type1, type42] Another fix for Savannah bug #43655.
* src/type1/t1load.c (parse_charstrings), src/type42/t42parse.c
(t42_parse_charstrings): Add another boundary testing.
2014-11-24 07:30:05 +01:00
Werner Lemberg 3788187e0c [type42] Fix Savannah bug #43659.
* src/type42/t42objs.c (T42_Open_Face): Initialize `face->ttf_size'.

* src/type42/t42parse.c (t42_parse_sfnts): Always set
`face->ttf_size' directly.  This ensures a correct stream size in
the call to `FT_Open_Face', which follows after parsing, even for
buggy input data.
Fix error messages.
2014-11-22 10:46:47 +01:00
Werner Lemberg dd89710f0f [type1, type42] Fix Savannah bug #43655.
* src/type1/t1load.c (parse_charstrings), src/type42/t42parse.c
(t42_parse_charstrings): Fix boundary testing.
2014-11-21 22:19:28 +01:00
Werner Lemberg 8b281f83e8 Fix Savannah bug #41309.
* src/type1/t1load.c (t1_parse_font_matrix): Properly handle result
of `T1_ToFixedArray'.

* src/cid/cidload.c (cid_parse_font_matrix): Synchronize with
`t1_parse_font_matrix'.

* src/type42/t42parse.c (t42_parse_font_matrix): Synchronize with
`t1_parse_font_matrix'.
(t42_parse_encoding): Synchronize with `t1_parse_encoding'.

* src/psaux/psobjs.c (ps_parser_load_field) <T1_FIELD_TYPE_BBOX>,
<T1_FIELD_TYPE_MMOX>: Properly handle result of `ps_tofixedarray'.
2014-01-23 08:14:53 +01:00