1
0
mirror of https://github.com/glennrp/libpng.git synced 2026-10-24 08:39:18 +03:00

4748 Commits

Author SHA1 Message Date
Cosmin Truta
ed739a508e ci: Enumerate all maintained branches in the GitHub Actions triggers 2026-10-02 19:20:05 +03:00
Cosmin Truta
d9b8b8ca78 fix(build): Link pnggetset against libpng2 in the configure build
This fixes a regression introduced during the merge of tag 'v1.6.57'
into branch 'libpng18' and further into branch 'develop'. That merge
brought in `pnggetset_LDADD` with the libpng 1.x library name
`libpng@PNGLIB_MAJOR@@PNGLIB_MINOR@.la`, which incorrectly resolved
to `libpng20.la` on 'develop'. The correct library name on this branch
is `libpng2.la`.
2026-10-02 18:47:30 +03:00
Cosmin Truta
0eb0c29eca Merge tag 'v1.6.59' into branch 'libpng18' into develop 2026-09-30 11:59:55 +03:00
Cosmin Truta
8334628be9 Merge tag 'v1.6.59' into libpng18 2026-09-30 11:59:55 +03:00
Cosmin Truta
cd952f49f9 Release libpng version 1.6.59 v1.6.59 2026-09-28 23:58:10 +03:00
Cosmin Truta
65152c0657 maint: Rerun ./autogen.sh --maintainer 2026-09-28 23:39:32 +03:00
Cosmin Truta
f5c2d04744 maint: Apply the MIT-0 license to .appveyor.yml
Signed-off-by: Cosmin Truta <ctruta@gmail.com>
2026-09-28 22:46:35 +03:00
Cosmin Truta
d9bdad6975 maint: Apply the MIT-0 license to .appveyor.yml
This is a cherry-pick of commit f5c2d04744
from branch 'libpng18'.

Signed-off-by: Cosmin Truta <ctruta@gmail.com>
2026-09-28 22:46:35 +03:00
Cosmin Truta
5e9b33f631 ci: Migrate the GitHub Actions Windows ARM64 job to Visual Studio 2026
Use the "Visual Studio 18 2026" CMake generator in all Windows jobs
of the GitHub Actions workflow. After the "windows-11-arm" label was
repointed to a new image that contains Visual Studio 2026 only, the
previous version-exact generator on Windows ARM64 no longer matched
any installed instance.
2026-09-28 22:34:48 +03:00
Cosmin Truta
83f925f34e ci: Migrate the GitHub Actions Windows ARM64 job to Visual Studio 2026
Use the "Visual Studio 18 2026" CMake generator in all Windows jobs
of the GitHub Actions workflow. After the "windows-11-arm" label was
repointed to a new image that contains Visual Studio 2026 only, the
previous version-exact generator on Windows ARM64 no longer matched
any installed instance.

This is a cherry-pick of commit 5e9b33f631
from branch 'libpng18'.
2026-09-28 22:34:48 +03:00
Cosmin Truta
ba947ba18e doc: Describe the zstream states that png_read_end must handle 2026-09-23 21:46:57 +03:00
Cosmin Truta
a6a75395be doc: Describe the zstream states that png_read_end must handle
This is a cherry-pick of commit ba947ba18e
from branch 'libpng18'.
2026-09-23 21:46:57 +03:00
Cosmin Truta
6c7783b151 fix: Clear stale zstream pointers when releasing the inflate stream
The zstream buffer pointers and counters are all cleared on acquisition
in `png_inflate_claim`, but only `next_in` and `avail_in` were cleared
on release in `png_read_finish_IDAT`, and none were cleared on release
in the chunk decompression paths.

If `png_read_end` is called before row reading starts, the IDAT stream
is never claimed. Previously, a leftover non-zero `avail_in` caused the
refill in `png_read_IDAT_data` to be skipped, and inflation continued
through a stale `next_in` into an input buffer that may since have been
deallocated.

Introduce the function `png_inflate_detach_buffers` to clear the
pointers and the counters of zstream input and output buffers on both
acquisition and release. Although clearing `next_out` and `avail_out`
is not currently necessary at any call site, it makes release mirror
acquisition at a negligible cost paid once for each zlib stream.

Reported-by: Ze Sheng <OwenSanzas@users.noreply.github.com>
Reported-by: JasonHonKL <JasonHonKL@users.noreply.github.com>
2026-09-23 18:30:11 +03:00
Cosmin Truta
aa77ef38c1 fix: Clear stale zstream pointers when releasing the inflate stream
The zstream buffer pointers and counters are all cleared on acquisition
in `png_inflate_claim`, but only `next_in` and `avail_in` were cleared
on release in `png_read_finish_IDAT`, and none were cleared on release
in the chunk decompression paths.

If `png_read_end` is called before row reading starts, the IDAT stream
is never claimed. Previously, a leftover non-zero `avail_in` caused the
refill in `png_read_IDAT_data` to be skipped, and inflation continued
through a stale `next_in` into an input buffer that may since have been
deallocated.

Introduce the function `png_inflate_detach_buffers` to clear the
pointers and the counters of zstream input and output buffers on both
acquisition and release. Although clearing `next_out` and `avail_out`
is not currently necessary at any call site, it makes release mirror
acquisition at a negligible cost paid once for each zlib stream.

This is a cherry-pick of commit 6c7783b151
from branch 'libpng18'.

Reported-by: Ze Sheng <OwenSanzas@users.noreply.github.com>
Reported-by: JasonHonKL <JasonHonKL@users.noreply.github.com>
2026-09-23 18:30:11 +03:00
Cosmin Truta
964b413594 ci: Remove the autotools install from the Linux verification job
All necessary autotools packages are now preinstalled in the GitHub
Actions Ubuntu runner images.
2026-09-11 22:47:43 +03:00
Cosmin Truta
4eeb825ab2 ci: Remove the autotools install from the Linux verification job
All necessary autotools packages are now preinstalled in the GitHub
Actions Ubuntu runner images.

This is a cherry-pick of commit 964b413594
from branch 'libpng18'.
2026-09-11 22:47:43 +03:00
Alb3e3
ef395b942d ci: Harden GitHub Actions workflow permissions
Without an explicit declaration, the workflow token carries write
access to the repository on push events, although our project only
needs read access. Restrict the grant to limit what a compromised
action can reach.

Also harden the dependency step: replace context expressions such as
`${{ github.ref }}` with environment variables to prevent expansion
as shell code.

Resolves: https://github.com/pnggroup/libpng/pull/879
Reviewed-by: Cosmin Truta <ctruta@gmail.com>
Signed-off-by: Cosmin Truta <ctruta@gmail.com>
2026-09-11 21:53:07 +03:00
Alb3e3
66cb28a0cd ci: Harden GitHub Actions workflow permissions
Without an explicit declaration, the workflow token carries write
access to the repository on push events, although our project only
needs read access. Restrict the grant to limit what a compromised
action can reach.

Also harden the dependency step: replace context expressions such as
`${{ github.ref }}` with environment variables to prevent expansion
as shell code.

This is a cherry-pick of commit ef395b942d
from branch 'libpng18'.

Resolves: https://github.com/pnggroup/libpng/pull/879
Reviewed-by: Cosmin Truta <ctruta@gmail.com>
Signed-off-by: Cosmin Truta <ctruta@gmail.com>
2026-09-11 21:53:07 +03:00
Cosmin Truta
dda1ea6914 doc: Update AUTHORS.md 2026-09-07 11:56:26 +03:00
Cosmin Truta
d636385b22 doc: Update AUTHORS.md
This is a cherry-pick of commit dda1ea6914
from branch 'libpng18'.
2026-09-07 11:56:26 +03:00
Yuki Sekiguchi
813a4963b1 Fix hIST chunk position to match W3C specification
The hIST chunk was incorrectly positioned in the code. According to the
W3C specification, the hIST chunk must appear before the first IDAT
chunk and after PLTE (if present). This commit corrects the chunk
positioning to comply with the specification.

This is a cherry-pick of commit 9ecda6eaf5
from branch 'libpng18'.

Signed-off-by: Chris Lilley <chris@w3.org>
Signed-off-by: Cosmin Truta <ctruta@gmail.com>
2026-09-07 11:56:26 +03:00
Yuki Sekiguchi
45126c6e67 Add test cases for hIST chunk
This is a cherry-pick of commit c2831cb0e6
from branch 'libpng18'.

Signed-off-by: Chris Lilley <chris@w3.org>
Signed-off-by: Cosmin Truta <ctruta@gmail.com>
2026-09-07 11:56:26 +03:00
Chris Lilley
d1d0abeffe Merge pull request #759 from aYukiSekiguchi/fix_hIST_chunk_position
Fix hIST chunk position to match W3C specification
2026-06-26 18:37:31 +03:00
Anthony Hurtado
cae4745589 fix: Prevent double-freeing png_struct members on allocation failure
Clear the pointers inside `png_struct` after `png_free`, following the
existing idiom in `png_read_buffer`, to ensure that a subsequent free
will be a no-op.

Several read-side functions free a `png_struct` member and allocate
a replacement without clearing the pointer in between. When that
allocation fails, `png_malloc` calls `png_error`, which longjmps out
before the assignment, leaving the member pointing at freed memory.
The application's cleanup path (`png_destroy_read_struct`, then
`png_read_destroy`) then frees it a second time.

The same defect occurs at five members across four functions:
 - `big_row_buf` and `big_prev_row` in `png_read_start_row`;
 - `palette` in `png_set_PLTE`;
 - `trans_alpha` in `png_set_tRNS`;
 - `quantize_index` in `png_set_quantize`.

This is robustness hardening, not a fix for untrusted input. Arming
the double-free needs a prior successful pass through the same site,
and PNG content alone cannot deliver one: duplicate PLTE and tRNS
chunks are rejected before their setters run, and within a single
decode the row dimensions never grow, so the row-buffer reallocation
guard cannot re-fire.

The trigger is an application that causes a setter to run twice on one
`png_struct` or reuses the struct across decodes, and then meets an
allocation failure.

This is a cherry-pick of commit a22696be0a
from branch 'libpng18'.

Co-authored-by: Cosmin Truta <ctruta@gmail.com>
Signed-off-by: Anthony Hurtado <amhurtado@pm.me>
Signed-off-by: Cosmin Truta <ctruta@gmail.com>
2026-06-22 19:38:52 +03:00
Anthony Hurtado
a22696be0a fix: Prevent double-freeing png_struct members on allocation failure
Clear the pointers inside `png_struct` after `png_free`, following the
existing idiom in `png_read_buffer`, to ensure that a subsequent free
will be a no-op.

Several read-side functions free a `png_struct` member and allocate
a replacement without clearing the pointer in between. When that
allocation fails, `png_malloc` calls `png_error`, which longjmps out
before the assignment, leaving the member pointing at freed memory.
The application's cleanup path (`png_destroy_read_struct`, then
`png_read_destroy`) then frees it a second time.

The same defect occurs at five members across four functions:
 - `big_row_buf` and `big_prev_row` in `png_read_start_row`;
 - `palette` in `png_set_PLTE`;
 - `trans_alpha` in `png_set_tRNS`;
 - `quantize_index` in `png_set_quantize`.

This is robustness hardening, not a fix for untrusted input. Arming
the double-free needs a prior successful pass through the same site,
and PNG content alone cannot deliver one: duplicate PLTE and tRNS
chunks are rejected before their setters run, and, although APNG
re-runs `png_read_start_row` on every frame, fcTL validation caps
each frame to the first frame's dimensions, so the row-buffer
reallocation guard cannot re-fire within one decode.

The trigger is an application that causes a setter to run twice on one
`png_struct` or reuses the struct across decodes, and then meets an
allocation failure.

Co-authored-by: Cosmin Truta <ctruta@gmail.com>
Signed-off-by: Anthony Hurtado <amhurtado@pm.me>
Signed-off-by: Cosmin Truta <ctruta@gmail.com>
2026-06-22 19:38:52 +03:00
Cosmin Truta
7ed557b4a0 build: Raise the CMake policy maximum version to 4.4
This is a cherry-pick of commit 6d2054b29e
from branch 'libpng18'.
2026-06-19 23:57:54 +03:00
Cosmin Truta
6d2054b29e build: Raise the CMake policy maximum version to 4.4 2026-06-19 23:57:54 +03:00
yaito3014
fad0b25433 fix(build): Use space-separated string for CMAKE_REQUIRED_FLAGS
This is a cherry-pick of commit d733c11206
from branch 'libpng18'.

Co-authored-by: Brad King <brad.king@kitware.com>
Signed-off-by: Cosmin Truta <ctruta@gmail.com>
2026-06-19 23:54:59 +03:00
yaito3014
d733c11206 fix(build): Use space-separated string for CMAKE_REQUIRED_FLAGS
Co-authored-by: Brad King <brad.king@kitware.com>
Signed-off-by: Cosmin Truta <ctruta@gmail.com>
2026-06-19 23:54:59 +03:00
Carlo Bramini
78ae423bf0 build: Fix wrong symlink created for import library on MinGW and Cygwin
This is a cherry-pick of commit 0bb2bb50e3
from branch 'libpng18'

Resolves: https://github.com/pnggroup/libpng/issues/783
Reviewed-by: Cosmin Truta <ctruta@gmail.com>
Signed-off-by: Cosmin Truta <ctruta@gmail.com>
2026-06-19 11:54:25 +03:00
Carlo Bramini
0bb2bb50e3 build: Fix wrong symlink created for import library on MinGW and Cygwin
Resolves: https://github.com/pnggroup/libpng/issues/783
Reviewed-by: Cosmin Truta <ctruta@gmail.com>
Signed-off-by: Cosmin Truta <ctruta@gmail.com>
2026-06-19 11:54:25 +03:00
Cosmin Truta
145eced09d ci: Migrate the Windows x64 job to Visual Studio 2026 on "windows-2025"
The "windows-latest" alias was repointed to a Windows Server 2025 image
that ships Visual Studio 2026 only, which prevented the version-exact
generator "Visual Studio 17 2022" from matching any installed instance.

This is a cherry-pick of commit dd5d363ae1
from branch 'libpng18'.
2026-06-15 22:54:19 +03:00
Cosmin Truta
dd5d363ae1 ci: Migrate the Windows x64 job to Visual Studio 2026 on "windows-2025"
The "windows-latest" alias was repointed to a Windows Server 2025 image
that ships Visual Studio 2026 only, which prevented the version-exact
generator "Visual Studio 17 2022" from matching any installed instance.
2026-06-15 22:54:19 +03:00
MUGUNDAN
99652c9987 ci: Add support for testing libpng on Windows ARM64
This is a cherry-pick of commit 92c853c34e
from branch 'libpng18'.

Co-authored-by: Cosmin Truta <ctruta@gmail.com>
Signed-off-by: Cosmin Truta <ctruta@gmail.com>
2026-05-11 20:31:55 +03:00
MUGUNDAN
92c853c34e ci: Add support for testing libpng on Windows ARM64
Co-authored-by: Cosmin Truta <ctruta@gmail.com>
Signed-off-by: Cosmin Truta <ctruta@gmail.com>
2026-05-11 20:31:55 +03:00
Cosmin Truta
7b85a6f566 maint: Apply the MIT-0 license to .github/workflows/
This is a cherry-pick of commit 76745cede9
from branch 'libpng18'.

Signed-off-by: Cosmin Truta <ctruta@gmail.com>
2026-05-11 11:09:22 +03:00
Cosmin Truta
76745cede9 maint: Apply the MIT-0 license to .github/workflows/
Signed-off-by: Cosmin Truta <ctruta@gmail.com>
2026-05-11 11:09:22 +03:00
Cosmin Truta
d3f14cdc8c maint: Migrate the CI software licensing to the REUSE Specification
Also change the copyright notice format in source files:

 - Old format: "Copyright (c) <Author> <Year>-<Year>"
 - New format: "Copyright (C) <Author> <Year>"

The new format is meant to reduce the diff output and to alleviate the
maintenance burden; the use of lowercase "(c)" vs. uppercase "(C)" is
meant to distinguish between the old format and the new format.

This is a cherry-pick of commit 28cb31ffa4
from branch 'libpng18'.

Signed-off-by: Cosmin Truta <ctruta@gmail.com>
2026-05-11 10:47:08 +03:00
Cosmin Truta
28cb31ffa4 maint: Migrate the CI software licensing to the REUSE Specification
Also change the copyright notice format in source files:

 - Old format: "Copyright (c) <Author> <Year>-<Year>"
 - New format: "Copyright (C) <Author> <Year>"

The new format is meant to reduce the diff output and to alleviate the
maintenance burden; the use of lowercase "(c)" vs. uppercase "(C)" is
meant to distinguish between the old format and the new format.

Signed-off-by: Cosmin Truta <ctruta@gmail.com>
2026-05-11 10:47:08 +03:00
Cosmin Truta
9ec49c2d56 fix(apng): Detect short fdAT chunks in push mode
Reported-by: Ryo Shimada <shimarda@users.noreply.github.com>
Resolves: https://github.com/pnggroup/libpng/issues/854
2026-04-29 23:04:55 +03:00
Cosmin Truta
8c62c3b86a Bump version to 1.6.59.git 2026-04-22 21:32:07 +03:00
Cosmin Truta
d2e19e86a0 Merge tag 'v1.6.58' into branch 'libpng18' into develop 2026-04-15 22:01:50 +03:00
Cosmin Truta
614ab644f8 Merge tag 'v1.6.58' into libpng18 2026-04-15 22:01:50 +03:00
Cosmin Truta
3061454d98 Release libpng version 1.6.58 v1.6.58 2026-04-15 20:23:26 +03:00
Cosmin Truta
6eb1ad8a2a chore: Update .gitignore to exclude the recently-added test program 2026-04-15 19:56:39 +03:00
Cosmin Truta
571a895143 test: Ensure the palette sync follows the gamma correction
This tests commit d4c4e49eb5.
2026-04-15 19:43:01 +03:00
Cosmin Truta
d4c4e49eb5 fix: Sync info_ptr->palette unconditionally after in-place transforms
The palette sync in `png_read_transform_info` was guarded by
`if (transformations != 0)`, but the palette-modifying transforms clear
their own bits before this function gets to run. When one of these was
the sole transform, the guard was false and the sync was skipped, which
caused `png_get_PLTE` to return stale palette data.

Drop this guard.

This was a regression from commit c1b0318b39 (version 1.6.56).

Reported-by: ralfjunker <ralfjunker@users.noreply.github.com>
Resolves: https://github.com/pnggroup/libpng/issues/848
2026-04-15 14:58:35 +03:00
Cosmin Truta
ac07fb0819 Bump version to 1.6.58.git 2026-04-15 11:46:46 +03:00
Cosmin Truta
faf0692468 fix: Consume chunk body in APNG push-mode discard paths
Restructure the trailing-fdAT path in the APNG push reader to check
`PNG_HAVE_fcTL` before calling `png_ensure_sequence_number`, in order
to ensure that an early return from insufficient buffer data cannot
sit between the sequence read and the body consumption.

Three inter-frame discard paths in `png_push_read_chunk` used to clear
the chunk-header flag without first consuming the chunk body and the
CRC field. On a subsequent call to `png_process_data`, the unconsumed
chunk bytes were reinterpreted as a fresh chunk header, which allowed
attacker-controlled data inside an ignored chunk to be smuggled into
the frame-data path.

Reported-by: 신승민 <guncraft2000@naver.com>
2026-04-13 13:51:09 +03:00
Cosmin Truta
4543ed7c00 Merge tag 'v1.6.57' into branch 'libpng18' into develop 2026-04-13 11:45:26 +03:00