4450 Commits

Author SHA1 Message Date
Cosmin Truta
ee9d6d7bf2 ci: Improve the support for cross-build verifications
Introduce CI_TARGET_TRIPLET and CI_TARGET_ABI.

Rename CI_HOST_MACHINE and CI_TARGET_MACHINE, respectively, to
CI_HOST_ARCH and CI_TARGET_ARCH, following on the conventional
target triplet nomenclature.

Introduce CI_BUILD_SYSTEM and CI_BUILD_ARCH, following on the
GNU Autotools (host/build/target) practice and nomenclature.

Ensure that CI_TARGET_SYSTEM, CI_TARGET_ARCH and CI_TARGET_ABI
are all initialized when verifying a cross-platform build.

Work around an obscure CMake error by ensuring that CMake variables
(CMAKE_AR and CMAKE_RANLIB) are initialized to the full executable
paths of their CI_* equivalents (CI_AR and CI_RANLIB).

Implement other general-purpose improvements:
 * Check all CI_NO_* variables in an arithmetic context, to allow
   setting them explicitly to zero in external configurations.
 * Label the assertions with descriptions of what's being asserted.
 * Add more comments and tracing printouts.
2023-07-30 17:07:25 +03:00
Cosmin Truta
f8e5fa92b0 ci: Fix ci_verify_cmake.sh; improve ci.lib.sh
Fix ci_verify_cmake.sh: sync up CI_BUILD_TO_INSTALL_RELDIR with
CI_INSTALL_DIR. (Oopsie!)

Replace slashes, backslashes and dots with underlines in system
names and machine hardware names. These names are now included in
the output directory naming scheme.
2023-07-09 12:27:51 +03:00
Cosmin Truta
c81516e943 ci: Fix bad copy pasta in ci_verify_configure.sh 2023-07-08 23:46:53 +03:00
Cosmin Truta
0b7bc40de1 ci: Introduce CI_HOST_* and CI_TARGET_*
Replace CI_SYSTEM_NAME and CI_MACHINE_NAME with CI_HOST_SYSTEM and
CI_HOST_MACHINE, respectively.

Introduce CI_TARGET_SYSTEM and CI_TARGET_MACHINE, defaulting to
CI_HOST_SYSTEM and CI_HOST_MACHINE, respectively.

Use CI_TARGET_SYSTEM and CI_TARGET_MACHINE in the naming scheme of
target build and install directories, in order to allow concurrent
verification builds for multiple cross-platform targets.
2023-07-04 19:40:05 +03:00
Cosmin Truta
82414985c1 ci: Add ci_lint_ci.sh and .shellcheckrc
Add ci_lint_ci.sh for linting the CI config files and scripts.
The linting is based on yamllint and shellcheck.
2023-07-04 00:12:32 +03:00
Cosmin Truta
c0616f1017 ci: Add ci.lib.ch; update ci_verify_*.sh accordingly
Move the common declarations and initializations from ci_verify_*.sh
to ci.lib.sh, and update them as follows:
 * Simplify the ci_ function names.
 * Refactor the CI_ variable names:
    - Add the new variable CI_TOPLEVEL_DIR.
    - Rename the variables CI_SCRIPTNAME, CI_SCRIPTDIR, etc.,
      to CI_SCRIPT_NAME, CI_SCRIPT_DIR, etc.
    - Rename the variables CI_SRCDIR_FROM_BUILDDIR, etc., to
      CI_BUILD_TO_SRC_RELDIR, etc.
 * Add new functions inside ci.lib.sh:
    - Replace ci_err with ci_err_usage, ci_err_fatal, ci_err_internal.
    - Add the new functions ci_warn and ci_assert.
 * Simplify the ci_ function names inside ci_verify_*.sh.
2023-07-03 22:59:24 +03:00
Cosmin Truta
c741d1e392 ci: Relicense the CI scripts to the Boost Software License version 1.0
Fetch LICENSE_BSL_1_0.txt from http://www.boost.org/LICENSE_1_0.txt
and update the copyright notice in all ci_* scripts.

Append "SPDX-License-Identifier" tags after each copyright notice;
see https://github.com/david-a-wheeler/spdx-tutorial/#spdx-tutorial
2023-07-03 19:14:33 +03:00
Cosmin Truta
ad9e42a877 Add .yamllint.yml, a configuration file for yamllint 2023-07-03 13:38:40 +03:00
Cosmin Truta
d7f77bf271 Bump version to 1.6.41.git 2023-06-26 11:09:17 +03:00
Cosmin Truta
f135775ad4 Release libpng version 1.6.40 v1.6.40 2023-06-21 22:06:40 +03:00
Cosmin Truta
afc6c595bf Fix a build regression on Solaris
Fix a regression introduced in commit aeb26da4cb64c0e75c8d.

On an Illumos test machine, running the GCC compiler and the Solaris
link editor, the CMake build failed with the following error:

    ld: fatal: unrecognized option '--version-script=/.../libpng.vers'

The fix consists in avoiding the use of CMAKE_SHARED_LIBRARY_C_FLAGS
in version script checks on Solaris.

Also clean up the surrounding code, as follows:
 * Rename CMAKE_REQUIRED_FLAGS_SAVE to _SAVED_CMAKE_REQUIRED_FLAGS.
   (The name of an internal variable should not begin with "CMAKE_".)
 * Reformat the version script to optimize the vertical space.
2023-06-21 21:08:40 +03:00
Cosmin Truta
e6c5bf46c4 Ensure that only one eXIf chunk is written in the entire datastream
EXIF data can be stored in an eXIf chunk before IDAT, or after IDAT,
but the entire PNG datastream may contain one eXIf chunk at most.

Introduce the private mode flag PNG_WROTE_eXIf, which is meant to be
used like the PNG_WROTE_tIME flag. The eXIf chunk and the tIME chunk
have the same ordering rules (i.e. no constraints are imposed), and
the same multiplicity rules (i.e. no multiples are allowed), and they
should be initialized and checked using the same algorithm.

This fixes commit cd03aaf7bf0e0c748b8c6cb34a56b402b40d61d0,
previously reverted in 3d57708c9166419b7f5e0bbda2f7a2149112c844.

Reported-by: Ben Bullock <benkasminbullock@gmail.com>
2023-06-21 16:16:07 +03:00
Wan-Teh Chang
8be5c147d5 Don't report a valid tRNS chunk if it was canceled
Add special handling of the PNG_INFO_tRNS flag to png_get_valid() to
not report a canceled tRNS chunk as valid.

Fix https://github.com/glennrp/libpng/issues/482

Signed-off-by: Cosmin Truta <ctruta@gmail.com>
2023-06-20 19:20:38 +03:00
Cosmin Truta
f7abe3c419 Avoid a memory leak when allocation of a pCAL buffer fails
Set the PNG_FREE_PCAL flag immediately after the allocation of the
first pCAL buffer, so that, if any one of the subsequent allocations
fail, all pCAL buffers still get deallocated by png_free_data.

Also reorder the initialization of other PNG_FREE_ flags (without
altering the semantics) to improve the overall consistency inside
the pngset.c module.

Co-authored-by: Philippe Antoine <contact@catenacyber.fr>
Signed-off-by: Cosmin Truta <ctruta@gmail.com>
2023-06-20 15:09:36 +03:00
Jesús González
82097c2108 Fix a doc typo in pnglibconf.dfa
Signed-off-by: Cosmin Truta <ctruta@gmail.com>
2023-02-16 15:34:29 +02:00
Cosmin Truta
e519af8b49 cmake: Allow overwriting the debug postfix of library filenames
Users may opt to change the debug suffix, e.g., from "d" to "_debug".

Rather than making CMAKE_DEBUG_POSTFIX a cache variable (which is
an antipattern in CMake), we introduce a new cache variable, named
PNG_DEBUG_POSTFIX.

Suggested-by: Diego Barrios Romero <eldruin@gmail.com>
2023-02-12 22:31:11 +02:00
Cosmin Truta
efc96c9d59 cmake: Redo the fix for Clang support on Windows
Redo commit 70fda1837d5de802ce5f7e04be239192b6a74d92, with a redesign.

Define the variables PNG_SHARED_OUTPUT_NAME and PNG_STATIC_OUTPUT_NAME
for the benefit of the OUTPUT_NAME target properties of, respectively,
the shared libpng build and the static libpng build. Fix and improve
not only Clang, but also other Windows toolchains, such as Embarcadero.

Rename the variable PNGLIB_SHARED_SOVERSION to PNG_ABI_VERSION.
The applicability of this variable, which is much wider than the old
name used to suggest, includes the definitions of PNG_*_OUTPUT_NAME.

Delete the confusingly-named variables PNGLIB_NAME and PNG_LIB_NAME,
and rename PNG_LIB_TARGETS to PNG_LIBRARY_TARGETS.

Set the macros _CRT_SECURE_NO_DEPRECATE and _CRT_NONSTDC_NO_DEPRECATE,
for all compilers that use MSVC run-time library headers. Currently,
these compilers are MSVC and Clang/Windows.

Add or improve the comments that accompany user-serviceable variables
and options.

Co-authored-by: B. Scott Michel <scooter.phd@gmail.com>
Signed-off-by: Cosmin Truta <ctruta@gmail.com>
2023-02-12 17:22:08 +02:00
Cosmin Truta
aab24fa1b3 Clean up CMakeLists.txt
* Rename the target `png` to `png_shared`. The main targets are now
   named `png_shared`, `png_static` and `png_framework`.
 * Rename the function symbol_prefix() to find_symbol_prefix().
 * Rename the prefix `S` to `_SYM` in the function create_symlink().
 * Rewrite the precondition checks in the function create_symlink().
 * Add precondition checks to the function generate_copy().
 * Delete the vestigial property CLEAN_DIRECT_OUTPUT.
 * Delete the variables PNG_LIB_NAME_STATIC and PNG_LIB_NAME_FRAMEWORK.
 * Initialize and use PNG_LIB_TARGETS consistently as a list.
 * Move all include() commands to the top of the file.
 * Acknowledge a former contributor.
 * Reformat.
2023-02-08 19:44:31 +02:00
Jeremy Maitin-Shepard
efa9c2e920 cmake: Rename the custom targets to have the png_ prefix
This avoids taget namespace pollution when including libpng as a
sub-project.

Signed-off-by: Cosmin Truta <ctruta@gmail.com>
2023-02-08 17:10:52 +02:00
Cosmin Truta
c22ef3b2e3 Revert "cmake: Fix the Clang support on Windows"
This reverts commit 70fda1837d5de802ce5f7e04be239192b6a74d92.

Fixing Clang on Windows is important. However, in the previous fix,
the name of the compiled libpng library file was changed, incorrectly,
on all platforms except Windows. A proper fix will follow up.
2023-02-07 17:49:06 +02:00
Cosmin Truta
66fede80d2 ci: Update the CI scripts
Apply the following changes:
 * Update CI_BUILDDIR and CI_INSTALLDIR to reflect the new script
   names.
 * Introduce CI_SRCDIR_FROM_BUILDDIR and CI_INSTALLDIR_FROM_BUILDDIR
   to the cmake build, to ensure that the Windows tools can handle
   native Windows paths correctly when executed via Bash-on-Windows.
 * Stop guessing and using CI_SRCDIR_NATIVE and CI_INSTALLDIR_NATIVE
   in the cmake build, since we now have a better solution.
 * Show the ninja program version in ninja-based cmake builds.
 * Move the cleanup of previous builds into separate functions, and
   do it in a cleaner manner. No pun intended.
2023-02-05 17:09:00 +02:00
Cosmin Truta
59fa76e164 ci: Add CMake+Ninja+Clang to the AppVeyor CI matrix 2023-02-04 20:33:23 +02:00
B. Scott Michel
70fda1837d cmake: Fix the Clang support on Windows
Fix a build error that occurs with the Ninja code generator and the
Clang compiler on Windows:

    ninja: error: build.ninja: multiple rules generate png16.lib

Signed-off-by: Cosmin Truta <ctruta@gmail.com>
2023-02-03 16:32:32 +02:00
Gunther Nikl
aeb26da4cb cmake: Use CMAKE_SHARED_LIBRARY_C_FLAGS in version script checks
Building the version script test executable may fail in the link step
with GNU ld as linker like this:

  ld: final link failed: Nonrepresentable section on output

Building the test excutable with CMAKE_SHARED_LIBRARY_C_FLAGS makes the
test succeed with GNU ld since this adds -fpic/-fPIC.

Signed-off-by: Cosmin Truta <ctruta@gmail.com>
2023-01-31 22:25:23 +02:00
Jon Creighton
cd0ea2a7f5 Fix for universal binaries on macOS
Fix the issue of a
    clang: error: no such file or directory: 'x86_64'
error on building universal binaries on macOS.

It is also necessary to specify:
    -DCMAKE_C_FLAGS="-DPNG_ARM_NEON_OPT=0"

Example CMake command:
    cmake -S libpng \
          -B build_libpng \
          -DCMAKE_OSX_ARCHITECTURES="arm64;x86_64" \
          -DCMAKE_C_FLAGS="-DPNG_ARM_NEON_OPT=0"

Signed-off-by: Cosmin Truta <ctruta@gmail.com>
2023-01-09 19:55:04 +02:00
Cosmin Truta
9923515ff4 Update the copyright year 2023-01-09 19:50:00 +02:00
Cosmin Truta
61bfdb0cb0 Update the configuration for Travis CI and AppVeyor CI
Simplify the test matrix on Travis CI to reduce the testing time.

Use CI_CMAKE_TOOLCHAIN_FILE on AppVeyor CI.
2022-11-29 12:38:45 +02:00
Cosmin Truta
9db8cff6ef ci: Fix verification under Cygwin Bash + CMake + Visual Studio; update
Fix autodetection and use of the cygpath executable on Windows.

Add a new variable CI_CMAKE_TOOLCHAIN_FILE to ci_verify_cmake.sh.
This should help in future cross-platform testing.

Remove the implicit initialization of CI_CC, CI_LD and CI_LIBS from
ci_verify_makefiles.sh. This should help the testing of default values
of their respective make variables (CC, LD and LIBS).
2022-11-27 21:58:07 +02:00
Cosmin Truta
b445aade83 ci: Rename the ci_* scripts
Give the CI scripts new names that better reflect what they do, and
make room for activities such as linting or dependency installation:
 * Rename ci_autotools.sh to ci_verify_configure.sh.
 * Rename ci_cmake.sh to ci_verify_cmake.sh.
 * Rename ci_legacy.sh to ci_verify_makefiles.sh.

Also rename CI_LEGACY_MAKEFILES to CI_MAKEFILES.

Update the config files for Travis CI and AppVeyor CI accordingly.
2022-11-27 21:05:42 +02:00
musvaage
3c152a8ef7 Fix typos
Signed-off-by: Cosmin Truta <ctruta@gmail.com>
2022-11-27 17:39:19 +02:00
Cosmin Truta
5a0b7e9c29 manuals: Remove references to libpngpf(3); update links
From libpng-1.5.0 onwards, the private libpng functions are no longer
accessible to the libpng users, and the content of libpngpf(3) is no
longer relevant.

Update links, introducing the new canonical location of the libpng
source repository:
https://github.com/pnggroup/libpng
2022-11-27 16:20:31 +02:00
Cosmin Truta
b126f80710 Reorganize and update the README file; add Markdown formatting 2022-11-27 16:20:31 +02:00
Cosmin Truta
3c761b5135 Bump version to 1.6.40.git 2022-11-27 13:10:35 +02:00
Cosmin Truta
07b8803110 Release libpng version 1.6.39 v1.6.39 2022-11-20 23:53:23 +02:00
Cosmin Truta
32f465a66b Update the file list in README 2022-11-20 23:53:23 +02:00
Paul Eggert
074e2eaab0 configure: Fix possible regressions with trunk autoconf (vs 2.71)
Signed-off-by: Cosmin Truta <ctruta@gmail.com>
2022-11-20 23:20:10 +02:00
John Bowler
790fef342b tools: Fix a memory leak in pngcp
Signed-off-by: Cosmin Truta <ctruta@gmail.com>
2022-11-20 23:03:43 +02:00
Alberto Barbaro
8a5732fcb3 tools: Fix a buffer overflow involving a file name in pngfix
Reported-by: Guoxiang Niu (@niugx), EaglEye Team
Reported-by: Riccardo Mori <patacca@autistici.org>
Reviewed-by: John Bowler <jbowler@acm.org>
Signed-off-by: Cosmin Truta <ctruta@gmail.com>
2022-11-20 22:28:03 +02:00
Cosmin Truta
77c3a39299 Clean up comments and whitespace characters in source files
Remove all remaining "last changed" version info from source comments.
(The version control system maintains this information automatically.)

Delete the trailing whitespace characters.
2022-11-20 21:23:33 +02:00
Cosmin Truta
8cfdb5436d Clean up oss-fuzz
With the caveat that oss-fuzz needs a full sync with upstream, here
are the changes applied to our old copy:
 * Add a missing #include directive.
 * Remove the "last changed" version info.
 * Clean up the trailing whitespace.

Co-authored-by: Ilya Yegorov <hkctkuy@gmail.com>
Co-authored-by: Cosmin Truta <ctruta@gmail.com>
Signed-off-by: Cosmin Truta <ctruta@gmail.com>
2022-11-20 21:13:14 +02:00
Cosmin Truta
f6036c0aeb Update, rename and clean up various scripts
Rename contrib/tools/chkfmt to contrib/tools/chkfmt.sh; refactor:
 * Increase the max line length for contrib/**/*.[ch] from 96 to 100.
 * Set the max line length for ci_*.sh to 100.
 * Use `basename $0` instead of the hard-coded script name.
 * Update comments.

Remove contrib/tools/reindent. For automated code formatting, including
indentation, we need a robust solution.

Add an empty line after the hashbang line in all scripts.

Remove the "last changed" version info from comment headers.
(The version control system maintains this information automatically.)
2022-11-20 20:21:41 +02:00
Cosmin Truta
689e06516b Clean up vestigial uses of png_size_tp 2022-11-20 17:51:33 +02:00
Cosmin Truta
33de006e12 Turn large PNG chunks into benign errors
Import Chromium commit
e87a029871

Add the author to the list of libpng contributing authors.

Portions from the original commit message follow:

***

A recent change to libpng [1] (included in Chromium with the recent
libpng update [2]) turns chunks that are bigger than
PNG_USER_CHUNK_MALLOC_MAX into failures. Although this matches the
intent of PNG_USER_CHUNK_MALLOC_MAX, it also causes images which used to
be viewable in Chromium to fail. Changing to a benign error allows us to
display these images once again. Though it means we do allow libpng to
allocate more than PNG_USER_CHUNK_MALLOC_MAX, it matches the behavior
prior to [2] (when we were using 1.6.22), and it does not regress
crbug.com/117369

[1] 347538efbd
[2] f82653a473

***

Bug: https://bugs.chromium.org/p/chromium/issues/detail?id=827754
Co-authored-by: Leon Scroggins III <scroggo@google.com>
Signed-off-by: Cosmin Truta <ctruta@gmail.com>
2022-11-20 00:56:35 +02:00
tangyaofang
9b5488054b Fix comments
Signed-off-by: Cosmin Truta <ctruta@gmail.com>
2022-11-16 01:51:34 +02:00
Felix Hanau
04c016d79f scripts: Fix the remaining instance of ZLIB_INCLUDE_DIR 2022-10-23 23:10:07 +03:00
Cosmin Truta
b8ca9108ac arm: Add a compile-time assertion about PNG_ARM_NEON_CHECK_SUPPORTED
Following up on the previous commit by Martin Storsjö:

If the availability of ARM Neon is not only known at compile time,
but also expected by the compiler's target architecture, there should
be no further need for a run-time check. In fact, such a check would
be counter-productive.
2022-10-12 12:42:09 +03:00
Martin Storsjö
e56f79c0c6 cmake: Default to PNG_ARM_NEON=off for arm targets
This matches the configure script - unless the user has requested
anything, no hardware optimizations are autoenabled.

Defaulting to "check" is brittle (that configuration is deprecated
and poorly supported) - and for configurations where it would
make sense (where NEON isn't universally enabled in the compiler)
it didn't end up setting ARM_NEON_OPT to 1 in pnglibconf.h anyway.

This fixes default builds with cmake for iOS and Windows on armv7,
where NEON is universally available (but there's no runtime check
implemented) - but actually using NEON on this architecture
requires explicitly opting in to it when configuring, just like
with the configure script.

Signed-off-by: Cosmin Truta <ctruta@gmail.com>
2022-10-12 12:35:33 +03:00
Cosmin Truta
12222e6fbd scripts: Add missing makefile.clang reference to README.txt 2022-09-18 23:51:58 +03:00
Cosmin Truta
9b65ad49d3 scripts: Remove the support for "install" targets from all makefiles
In most of the legacy makefiles (with only a few notable exceptions
such as makefile.linux), the "install" targets have been broken since
libpng-1.5.0beta01. Specifically, the "install-shared" targets produced
incorrect library names, due to a missing symbol in the definition of
the LIBSOREL macro.

Rather than correcting this long-standing and long-untested error, we
decided to remove the support for "make install" altogether, from all
legacy makefiles. Further use of "make install", "make install-static"
or "make install-shared" will fail with an error message.

Going forward, the only tested and supported manners to install libpng
shall be the conventional build and install procedures driven by the
configure script or by the CMake file.
2022-09-18 19:37:40 +03:00
Cosmin Truta
3f991d5092 scripts: Remove makefile.cegcc
It is obsolete and unlikely to be still working
2022-09-18 16:26:26 +03:00