Commit graph

9 commits

Author SHA1 Message Date
Adrian Johnson
0cae2a4a74 Use _cairo_calloc() to allocate structs
To avoid any possibility of uninitialized memory.

The exceptions are:
 - where the allocation is immediately overwritten by a memcpy or struct copy.
 - arrays of structs to avoid any performance impact (except when the
   array is returned by the public API).
2024-06-21 10:32:23 +09:30
Adrian Johnson
754f431642 Allow links to specify 'dest' and 'uri'
- If a link has both 'dest' and 'uri', the 'dest' will be used if it
  exists, otherwise it will fallback to using the 'uri'.

- Ensure that a missing 'dest' does not result in an error. Instead a
  warning is printed if CAIRO_DEBUG_TAG is set, and a link to the
  current location is embedded in the PDF. ie the link does
  nothing. Cairo needs to embed a link even if no destination is
  available because when links are embedded at the end of the
  document, the content stream already contains link tags.

- Remove cairo_pdf_interchange_write_forward_links. This code was
  originally used prior to !463 when cairo wrote the links at the end
  of each page. Now the links are written at the end of the document
  so there are no longer any forward links with an unknown
  destination, unless the destination does not exist.

- When 'internal' is not used, use the 'dest' name to reference the
  link. Ensure non ASCII names are correctly encoded.
2024-05-11 19:52:02 +09:30
Uli Schlachter
42555cb0a7 Merge branch 'tag_stack' into 'master'
Fix use-after-free in _cairo_tag_stack_pop

See merge request cairo/cairo!483
2023-06-29 15:11:17 +00:00
Jonathan Kew
4e0f76473f Fix use-after-free in _cairo_tag_stack_pop 2023-06-29 12:52:33 +00:00
Adrian Johnson
b53b48116e Make cairo_tag_begin/end work correctly in groups
Fixes #508
2023-04-18 18:27:12 +09:30
Adrian Johnson
24616585ec Print tag error details when CAIRO_DEBUG_TAG is defined
Add a _cairo_tag_error(fmt, ...) function that is used liked _cairo_error()
but allows an error message to be specified. When CAIRO_DEBUG_TAG is defined
the error is printed.
2021-07-29 06:00:37 +09:30
Adrian Johnson
1998239387 Use _cairo_malloc instead of malloc
_cairo_malloc(0) always returns NULL, but has not been used
consistently.  This patch replaces many calls to malloc() with
_cairo_malloc().

Fixes:  fdo# 101547
CVE: CVE-2017-9814 Heap buffer overflow at cairo-truetype-subset.c:1299
Reviewed-by: Bryce Harrington <bryce@osg.samsung.com>
2018-05-07 16:35:51 -07:00
Adrian Johnson
74c6e3ae1d pdf: don't write logical structure if it only contains links 2017-08-22 21:25:22 +09:30
Adrian Johnson
dcbfb72647 pdf: structured text and hyperlink support 2016-10-01 22:05:42 +09:30