Commit graph

12580 commits

Author SHA1 Message Date
Adrian Johnson
e8b622ebe6 Support check-def.sh in meson build
The original check-def.sh called make. In meson, check-def.sh is
replaced by two shell scripts, one for generating cairo.def, the other
for comparing with the library symbols.

The library filename appended to the cairo.def has been omitted as
this is only reqired in autotools builds where the cairo.def is also
to generate cairo.dll in the windows build.

make-cairo-def.sh is based on the cairo.def target in Makefile.am.
meson-check-def.sh is based on check-def.sh
2023-01-02 22:43:39 +10:30
Adrian Johnson
7f83c30943 Merge branch 'test-readme' into 'master'
Add README.meson file for meson test

See merge request cairo/cairo!385
2023-01-02 10:54:17 +00:00
Adrian Johnson
39081b0c40 Add README.meson file for meson test 2023-01-02 20:46:39 +10:30
Uli Schlachter
8dbc5893f7 Merge branch 'jpx-out-of-bounds' into 'master'
Fix possible out-of-bound reads in get_jpx_info

See merge request cairo/cairo!387
2023-01-02 09:28:42 +00:00
Uli Schlachter
3cc15cb40e Merge branch 'duplicate-ref-images' into 'master'
Remove duplicate reference images & run check-refs.sh in CI to ensure that no new duplicate images are added

See merge request cairo/cairo!384
2023-01-02 09:04:16 +00:00
Uli Schlachter
d9008ff8c1 Merge branch 'jbig2-out-of-bounds-read' into 'master'
Fix an out of bounds read in _jbig2_get_next_segment()

See merge request cairo/cairo!386
2023-01-02 09:04:00 +00:00
Uli Schlachter
e60e562fd1 Fix possible out-of-bound reads in get_jpx_info
Inspired by [1], I looked into the other functions in
cairo-image-info.c. This commit fixes the possible out-of-bound reads
that I found just by staring at the code.

_jpx_next_box() would happily read beyond the end of the data via
get_unaligned_be32(). This commit adds checks that at least for bytes of
data are available.

Additionally, I made this function check that its returned pointer is
within bounds, just because I found this easier to reason about.

Also, _jpx_extract_info() did not check that it had enough data to read.
This is fixed by making the function fallible and giving it information
about the end of data.

[1]: https://gitlab.freedesktop.org/cairo/cairo/-/merge_requests/386

Signed-off-by: Uli Schlachter <psychon@znc.in>
2023-01-01 14:01:46 +01:00
Uli Schlachter
d623090b32 Fix an out of bounds read in _jbig2_get_next_segment()
Fixes: https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=38451
Signed-off-by: Uli Schlachter <psychon@znc.in>
2023-01-01 09:43:33 +01:00
Adrian Johnson
c51b5e8021 Copy completion.bash to $builddir/test 2023-01-01 16:27:02 +10:30
Adrian Johnson
513c49e623 user-font-color test: draw glyphs again inside a group
This demonstrates a bug in user-fonts with foreground color inside a
group.
2023-01-01 14:00:00 +10:30
Uli Schlachter
52e964da69 Merge branch 'speed-up-coverage-column-triangles' into 'master'
Speed up coverage-column-triangles test

Closes #498

See merge request cairo/cairo!379
2022-12-31 17:30:29 +00:00
Simon McVittie
ff28595eff CI: Update test artifacts to be appropriate for out-of-tree Meson build
Signed-off-by: Simon McVittie <smcv@debian.org>
2022-12-31 17:09:40 +01:00
Uli Schlachter
fbd71a0a45 Switch CI tests from autotools to meson
The autotools build files are on their way out (See !298). As
preparation for dropping the autotools build, this commit switches CI to
run tests based on the meson build instead of the autotools one.

No functional changes intended.

Signed-off-by: Uli Schlachter <psychon@znc.in>
2022-12-31 17:09:40 +01:00
Uli Schlachter
7de261b0b1 Merge branch 'script-bug-277' into 'master'
script: Implement device finish

Closes #277

See merge request cairo/cairo!292
2022-12-31 15:13:59 +00:00
Uli Schlachter
997870601b Run check-refs.sh in CI
The check-refs.sh script detects duplicate reference images. This commit
adds it to be run by CI. For this, the script is extended with a proper
exit code.

Signed-off-by: Uli Schlachter <psychon@znc.in>
2022-12-31 16:05:27 +01:00
Uli Schlachter
d546a78c6f Remove duplicate reference images
Running test/check-refs.sh reports:

redundant: arc-direction.pdf.ref.png and arc-direction.ref.png are byte-by-byte identical files
redundant: big-little-triangle.traps.argb32.ref.png and big-little-triangle.argb32.ref.png are byte-by-byte identical files
redundant: big-little-triangle.traps.rgb24.ref.png and big-little-triangle.rgb24.ref.png are byte-by-byte identical files
redundant: clip-fill-rule.pdf.rgb24.ref.png and clip-fill-rule.rgb24.ref.png are byte-by-byte identical files
redundant: dash-offset-negative.pdf.ref.png and dash-offset-negative.ref.png are byte-by-byte identical files
redundant: font-matrix-translation.traps.ref.png and font-matrix-translation.ref.png are byte-by-byte identical files
redundant: ft-show-glyphs-positioning.traps.ref.png and ft-show-glyphs-positioning.ref.png are byte-by-byte identical files
redundant: ft-show-glyphs-table.traps.ref.png and ft-show-glyphs-table.ref.png are byte-by-byte identical files
redundant: glyph-cache-pressure.traps.ref.png and glyph-cache-pressure.ref.png are byte-by-byte identical files
redundant: inverse-text.traps.ref.png and inverse-text.ref.png are byte-by-byte identical files
redundant: line-width-large-overlap-offset.ps.ref.png and line-width-large-overlap-offset.ref.png are byte-by-byte identical files
redundant: partial-clip-text-right.traps.ref.png and partial-clip-text-right.ref.png are byte-by-byte identical files
redundant: partial-clip-text-top.traps.ref.png and partial-clip-text-top.ref.png are byte-by-byte identical files
redundant: record90-fill-alpha.pdf.ref.png and record90-fill-alpha.ref.png are byte-by-byte identical files
redundant: record90-paint-alpha-clip.quartz.ref.png and record90-paint-alpha-clip.ref.png are byte-by-byte identical files
redundant: record-fill-alpha.pdf.ref.png and record-fill-alpha.ref.png are byte-by-byte identical files
redundant: recordflip-whole-fill-alpha.quartz.ref.png and recordflip-whole-fill-alpha.ref.png are byte-by-byte identical files
redundant: recordflip-whole-paint-alpha-clip-mask.quartz.ref.png and recordflip-whole-paint-alpha-clip-mask.ref.png are byte-by-byte identical files
redundant: record-mesh.ps.ref.png and record-mesh.ref.png are byte-by-byte identical files
redundant: select-font-face.traps.ref.png and select-font-face.ref.png are byte-by-byte identical files
redundant: show-glyphs-advance.traps.ref.png and show-glyphs-advance.ref.png are byte-by-byte identical files
redundant: show-text-current-point.traps.ref.png and show-text-current-point.ref.png are byte-by-byte identical files
redundant: text-antialias-gray.traps.ref.png and text-antialias-gray.ref.png are byte-by-byte identical files

This commit removes these redundant files.

Signed-off-by: Uli Schlachter <psychon@znc.in>
2022-12-31 15:56:33 +01:00
Uli Schlachter
001df8ad17 Merge branch 'improve-offset-size-checking' into 'master'
Improve cff index reading code

See merge request cairo/cairo!383
2022-12-31 14:01:08 +00:00
Uli Schlachter
c24c657525 Improve cff index reading code
In a recent MR [1], Adrian Johnson writes:

  For additional safety you could change the unsigned long to size_t
  since long is 32-bits on Win64. The CFF spec says the offset size used
  in decode_index_offset must be between 1 and 4 so you could range
  check that to avoid overflowing the offset.

This commit implements exactly that.

[1]: https://gitlab.freedesktop.org/cairo/cairo/-/merge_requests/382#note_1700743

Signed-off-by: Uli Schlachter <psychon@znc.in>
2022-12-31 14:21:28 +01:00
Uli Schlachter
c56c3023bb Merge branch 'oob-cff-subset' into 'master'
Fix out-of-bounds access in cff subset

See merge request cairo/cairo!382
2022-12-31 13:20:07 +00:00
Uli Schlachter
aeafbf554f Merge branch 'clipper-memory-leak' into 'master'
Fix memory leak in type3 glyph surface

See merge request cairo/cairo!381
2022-12-31 13:18:03 +00:00
Uli Schlachter
cc656934da Fix a possible out-of-bounds read
While working on the previous commit, I noticed that nothing makes sure
that the entry points within the font data. Thus, this could easily
cause out-of-bounds reads.

This commit adds a suitable length check for this.

Signed-off-by: Uli Schlachter <psychon@znc.in>
2022-12-31 13:43:32 +01:00
Uli Schlachter
52760fc90e Fix out-of-bounds access in cff subset
I was looking at [1]. While trying to reproduce the problem that is
described there, valgrind reported:

 Argument 'size' of function malloc has a fishy (possibly negative) value: -8
    at 0x48407B4: malloc (in /usr/libexec/valgrind/vgpreload_memcheck-amd64-linux.so)
    by 0x4B20E92: cairo_cff_font_read_name (cairo-cff-subset.c:895)
    by 0x4B221AD: cairo_cff_font_read_font (cairo-cff-subset.c:1351)
    by 0x4B24EF2: cairo_cff_font_generate (cairo-cff-subset.c:2587)
    by 0x4B25EA3: _cairo_cff_subset_init (cairo-cff-subset.c:2979)

This commit is about fixing the above.

The function decode_index_offset() returns an unsigned long. This value
was cast to an "int" in cff_index_read(), leading to a possibility for
over/underflow. Also, nothing checked that an entry in the index table
had a non-zero length, leading to an entry with length -8 as reported by
valgrind.

Fix this by using "unsigned long" for the local variables and checking
the length to be non-negative.

With the above fixed, the original test case started crashing.
Apparently, cairo_cff_font_read_name() does not expect nor handle
failures from cff_index_read(). Thus, a check for this case was added to
make the new crash go away.

[1]: https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=51324

Signed-off-by: Uli Schlachter <psychon@znc.in>
2022-12-31 13:43:24 +01:00
Uli Schlachter
488209d9e9 Fix memory leak in type3 glyph surface
In _cairo_type3_glyph_surface_create(), we call
_cairo_surface_clipper_init(), but nothing ever called
_cairo_surface_clipper_reset() in this call. This commit adds that
missing call.

This fixes a leak of a clip.

Since I have no clue about this code (does _cairo_pdf_operators_fini()
possible use the clipper?), I did the patch like this. This should avoid
any possibility for a use-after-free.

Fixes: https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=51043
Signed-off-by: Uli Schlachter <psychon@znc.in>
2022-12-31 13:30:57 +01:00
Adrian Johnson
3a60f6e138 Merge branch 'ft-svg-fonts' into 'master'
Support SVG fonts in FT backend

See merge request cairo/cairo!319
2022-12-31 09:27:57 +00:00
Behdad Esfahbod
8c983c0d5d Merge branch 'malloc-stats' into 'master'
[malloc-stats] Fix to not crash

See merge request cairo/cairo!378
2022-12-30 18:12:27 +00:00
Behdad Esfahbod
71c4443139 [malloc-stats] Fix to not crash
Can't use constructor as malloc might be called before that.
2022-12-30 10:34:46 -07:00
Uli Schlachter
8d74c4d019 Speed up coverage-column-triangles test
This commit changes the height of the coverage-column-triangles test by
using a smaller height for the test. Previously the image was 40 pixels
in height and the test took 517 seconds for me. Now, the image has a
height of 4 pixels and the test takes 55 seconds.

This is possible since column_triangles() does the same thing for each y
coordinate. Thus, previously this test just did the same thing 40 times.

Times are measured with the backends I happened to have enabled locally:
script, xcb, xlib, image, recording.

Thanks a lot to Christian Rohlfs for coming up with this idea in
https://gitlab.freedesktop.org/cairo/cairo/-/issues/498#note_1700197

Possibly-fixes: https://gitlab.freedesktop.org/cairo/cairo/-/issues/498
Signed-off-by: Uli Schlachter <psychon@znc.in>
2022-12-30 16:36:22 +01:00
Uli Schlachter
35f2610f4d coverage.c: Use width/height arguments
The tests in coverage.c have #defines for WIDTH and HEIGHT, but also
have function arguments for these numbers. This commit changes the tests
to use the function arguments instead of the defines.

One complication is the rhombus test that already had a factor 2 between
these two numbers. A new variable is added to get back the previous
value.

Signed-off-by: Uli Schlachter <psychon@znc.in>
2022-12-30 09:29:10 +01:00
Uli Schlachter
4913f07950 Merge branch 'round-join' into 'master'
Remove `round-join-bug-520*` CI exceptions for Quartz backend

See merge request cairo/cairo!377
2022-12-29 12:37:01 +00:00
Christian Rohlfs
aa8d16ab83 Removed round-join-bug-520* CI exceptions for Quartz backend
Removed lines from `.gitlab-ci/ignore-quartz*`;
Added `round-join-bug-520-bevel.quartz.ref.png` file.
2022-12-28 17:50:27 +05:00
Uli Schlachter
2351a65b27 Merge branch 'test-ps' into 'master'
Test cairo-ps in CI

See merge request cairo/cairo!171
2022-12-28 10:52:56 +00:00
Uli Schlachter
a2d05a0c34 ps: Fix crash in self-copy-overlap
According to valgrind, there is a use-after-free here. The function
_cairo_ps_surface_emit_surface() temporarily replaces some member of a
struct and then later re-sets it. However, there is an early return
possible that would skip that part of the code.

This commit moves the re-set up so that no freed pointers are left
behind. This seems to fix the crash.

Signed-off-by: Uli Schlachter <psychon@znc.in>
2022-12-28 11:15:01 +01:00
Uli Schlachter
c1aaaff880 Test cairo-ps in CI
This adds the necessary dependencies for testing cairo-ps to CI and sets
up jobs for testing the ps2 and ps3 backends.

Signed-off-by: Uli Schlachter <psychon@znc.in>
2022-12-28 11:14:59 +01:00
Uli Schlachter
0e56ea9d5c Merge branch 'round-join' into 'master'
Fix for round joins

See merge request cairo/cairo!372
2022-12-28 09:58:35 +00:00
Adrian Johnson
394256abba Merge branch 'lzw-compress-1-byte' into 'master'
Fixed crash in _cairo_lzw_compress for 1 byte input

See merge request cairo/cairo!376
2022-12-28 09:55:37 +00:00
Daniel Hammerschmid
bd15b62906 Fixed crash in _cairo_lzw_compress for 1 byte input 2022-12-28 10:16:49 +01:00
Adrian Johnson
9b2e6f1994 Merge branch 'bash-completion' into 'master'
Bash completion for cairo-test-suite

See merge request cairo/cairo!375
2022-12-28 08:34:56 +00:00
Adrian Johnson
fab328598c Bash completion for cairo-test-suite
Usage:

$ source completion.bash
2022-12-28 16:16:18 +10:30
Adrian Johnson
0b5ec0139c Merge branch 'pbounds-size' into 'master'
Ensure pbounds.size is initialized even in EXTEND_NONE mode.

See merge request cairo/cairo!363
2022-12-28 05:42:51 +00:00
Adrian Johnson
7fa02c81f1 Merge branch 'bug-535' into 'master'
Fix bug #535 in cairo-script

Closes #535

See merge request cairo/cairo!276
2022-12-28 05:05:07 +00:00
Adrian Johnson
b13fb85982 Merge branch 'negative-version-values' into 'master'
cairo_pdf_version_to_string: Check for negative values

Closes #590

See merge request cairo/cairo!358
2022-12-28 04:49:59 +00:00
Adrian Johnson
2b862f632d Merge branch 'lzw_eod_code_width' into 'master'
Fix output of EOD code with incorrect code width in _cairo_lzw_compress

See merge request cairo/cairo!359
2022-12-28 04:45:26 +00:00
Adrian Johnson
3e8b9a7cf4 Add some missing slim_hidden entries 2022-12-28 14:00:33 +10:30
Adrian Johnson
1ba3e40d9c FT: support COLRv0 recording surface 2022-12-28 13:22:00 +10:30
Jonathan Kew
4f9b637123 Fix x/y typo in _cairo_pdf_surface_analyze_operation
This can result in spuriously returning UNSUPPORTED and generating rasterized output in cases where this isn't actually necessary.
2022-12-28 13:22:00 +10:30
Adrian Johnson
063f9db67e Fuzzer 2022-12-28 13:22:00 +10:30
Adrian Johnson
8233c6362b ft-svg-render test 2022-12-28 13:22:00 +10:30
Adrian Johnson
252ff60f1e SVG font test using cairo logo 2022-12-28 13:22:00 +10:30
Adrian Johnson
1bd5751324 FT SVG color font test 2022-12-28 13:22:00 +10:30
Adrian Johnson
31700fed4f Support SVG fonts in FT backend 2022-12-28 13:22:00 +10:30