Skip to content

Commit 48f09ea

Browse files
committed
Merge branch 'master' into message-proc-2
2 parents c417ab1 + 868a246 commit 48f09ea

10 files changed

Lines changed: 118 additions & 81 deletions

.github/workflows/cmake-multi-platform.yml

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -25,25 +25,21 @@ jobs:
2525
matrix:
2626
os: [ubuntu-latest, windows-latest]
2727
build_type: [Release]
28-
c_compiler: [gcc, clang, cl]
28+
c_compiler: [gcc, cl]
2929
include:
3030
- os: windows-latest
3131
c_compiler: cl
3232
cpp_compiler: cl
3333
- os: ubuntu-latest
3434
c_compiler: gcc
3535
cpp_compiler: g++
36-
- os: ubuntu-latest
37-
c_compiler: clang
38-
cpp_compiler: clang++
3936
exclude:
4037
- os: windows-latest
4138
c_compiler: gcc
42-
- os: windows-latest
43-
c_compiler: clang
4439
- os: ubuntu-latest
4540
c_compiler: cl
4641

42+
4743
steps:
4844
- uses: actions/checkout@v4
4945

@@ -63,6 +59,8 @@ jobs:
6359
-DCMAKE_C_COMPILER=${{ matrix.c_compiler }}
6460
-DCMAKE_BUILD_TYPE=${{ matrix.build_type }}
6561
-S ${{ github.workspace }}
62+
-DFREEIMAGE_WITH_LIBHEIF:BOOL=OFF
63+
-DFREEIMAGE_BUILD_TESTS:BOOL=ON
6664
6765
- name: Build
6866
# Build your program with the given configuration. Note that --config is needed because the default Windows generator is a multi-config generator (Visual Studio generator).
@@ -72,4 +70,5 @@ jobs:
7270
working-directory: ${{ steps.strings.outputs.build-output-dir }}
7371
# Execute tests defined by the CMake configuration. Note that --build-config is needed because the default Windows generator is a multi-config generator (Visual Studio generator).
7472
# See https://cmake.org/cmake/help/latest/manual/ctest.1.html for more detail
75-
run: ctest --build-config ${{ matrix.build_type }}
73+
# run: ctest --build-config ${{ matrix.build_type }}
74+
run: echo "Tests are skipped"

CMakeLists.txt

Lines changed: 22 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,20 @@
11
cmake_minimum_required(VERSION 3.28)
22

3-
set_property(GLOBAL PROPERTY USE_FOLDERS ON)
4-
53
project(FreeImageRe)
64

75
set(FREEIMAGERE_MAJOR_VERSION "0")
86
set(FREEIMAGERE_MINOR_VERSION "6")
97

10-
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)
11-
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)
12-
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)
8+
if (PROJECT_IS_TOP_LEVEL)
9+
set_property(GLOBAL PROPERTY USE_FOLDERS ON)
10+
11+
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)
12+
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)
13+
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)
14+
15+
set(CMAKE_INSTALL_DOCDIR doc)
16+
endif()
1317

14-
set(CMAKE_INSTALL_DOCDIR doc)
1518

1619
set(CMAKE_POLICY_DEFAULT_CMP0077 "NEW")
1720
cmake_policy(SET CMP0079 NEW) # -> target_link_libraries() allows use with targets in other directories.
@@ -25,62 +28,62 @@ set(CMAKE_CXX_STANDARD 17)
2528
set(CMAKE_CXX_STANDARD_REQUIRED ON)
2629

2730
# External dependencies
28-
include(${CMAKE_SOURCE_DIR}/cmake/dependency.zlib.cmake)
29-
include(${CMAKE_SOURCE_DIR}/cmake/dependency.yato.cmake)
31+
include(${CMAKE_CURRENT_SOURCE_DIR}/cmake/dependency.zlib.cmake)
32+
include(${CMAKE_CURRENT_SOURCE_DIR}/cmake/dependency.yato.cmake)
3033

3134
option(FREEIMAGE_WITH_LIBJPEG "Compile with the LibJPEG backend" ON)
3235
if (FREEIMAGE_WITH_LIBJPEG)
33-
include(${CMAKE_SOURCE_DIR}/cmake/dependency.jpeg.cmake)
36+
include(${CMAKE_CURRENT_SOURCE_DIR}/cmake/dependency.jpeg.cmake)
3437
endif()
3538

3639
option(FREEIMAGE_WITH_LIBOPENJPEG "Compile with the LibOpenJPEG backend" ON)
3740
if (FREEIMAGE_WITH_LIBOPENJPEG)
38-
include(${CMAKE_SOURCE_DIR}/cmake/dependency.openjpeg.cmake)
41+
include(${CMAKE_CURRENT_SOURCE_DIR}/cmake/dependency.openjpeg.cmake)
3942
endif()
4043

4144
option(FREEIMAGE_WITH_LIBOPENEXR "Compile with the LibOpenEXR backend" ON)
4245
if (FREEIMAGE_WITH_LIBOPENEXR)
43-
include(${CMAKE_SOURCE_DIR}/cmake/dependency.openexr.cmake)
46+
include(${CMAKE_CURRENT_SOURCE_DIR}/cmake/dependency.openexr.cmake)
4447
endif()
4548

4649
option(FREEIMAGE_WITH_LIBPNG "Compile with the LibPNG backend" ON)
4750
if (FREEIMAGE_WITH_LIBPNG)
48-
include(${CMAKE_SOURCE_DIR}/cmake/dependency.png.cmake)
51+
include(${CMAKE_CURRENT_SOURCE_DIR}/cmake/dependency.png.cmake)
4952
endif()
5053

5154
option(FREEIMAGE_WITH_LIBTIFF "Compile with the LibTIFF backend" ON)
5255
if (FREEIMAGE_WITH_LIBTIFF)
53-
include(${CMAKE_SOURCE_DIR}/cmake/dependency.tiff.cmake)
56+
include(${CMAKE_CURRENT_SOURCE_DIR}/cmake/dependency.tiff.cmake)
5457
endif()
5558

5659
option(FREEIMAGE_WITH_LIBWEBP "Compile with the LibWEBP backend" ON)
5760
if (FREEIMAGE_WITH_LIBWEBP)
58-
include(${CMAKE_SOURCE_DIR}/cmake/dependency.webp.cmake)
61+
include(${CMAKE_CURRENT_SOURCE_DIR}/cmake/dependency.webp.cmake)
5962
endif()
6063

6164
option(FREEIMAGE_WITH_LIBRAW "Compile with the LibRAW backend" ON)
6265
if (FREEIMAGE_WITH_LIBRAW)
63-
include(${CMAKE_SOURCE_DIR}/cmake/dependency.raw.cmake)
66+
include(${CMAKE_CURRENT_SOURCE_DIR}/cmake/dependency.raw.cmake)
6467
endif()
6568

6669
option(FREEIMAGE_WITH_LIBHEIF "Compile with the LibHEIF backend" ON)
6770
if (FREEIMAGE_WITH_LIBHEIF)
68-
include(${CMAKE_SOURCE_DIR}/cmake/dependency.heif.cmake)
71+
include(${CMAKE_CURRENT_SOURCE_DIR}/cmake/dependency.heif.cmake)
6972
endif()
7073

7174
option(FREEIMAGE_WITH_PYTHON_BINDINGS "Build pythin bindings" OFF)
7275
if (FREEIMAGE_WITH_PYTHON_BINDINGS)
7376
find_package(Python3 COMPONENTS Development REQUIRED)
74-
include(${CMAKE_SOURCE_DIR}/cmake/dependency.pybind.cmake)
77+
include(${CMAKE_CURRENT_SOURCE_DIR}/cmake/dependency.pybind.cmake)
7578
endif()
7679

7780
# Internal dependencies
7881
option(FREEIMAGE_WITH_LIBJXR "Compile with the LibJXR backend" ON)
7982
if (FREEIMAGE_WITH_LIBJXR)
80-
add_subdirectory(${CMAKE_SOURCE_DIR}/3rdParty/LibJXR ${CMAKE_BINARY_DIR}/LibJXR)
83+
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/3rdParty/LibJXR ${CMAKE_BINARY_DIR}/LibJXR)
8184
endif()
8285

83-
set(FREEIMAGE_INCLUDE_DIR ${CMAKE_SOURCE_DIR}/Source)
86+
set(FREEIMAGE_INCLUDE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/Source)
8487

8588
add_definitions("-DFREEIMAGERE_MAJOR_VERSION=${FREEIMAGERE_MAJOR_VERSION}")
8689
add_definitions("-DFREEIMAGERE_MINOR_VERSION=${FREEIMAGERE_MINOR_VERSION}")

Readme.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,9 +127,10 @@ Version 0.5:
127127
Version 0.6:
128128
- Added support of extra TIFF image formats
129129
- Fixed infinite loop in TIFF thumbnail loading
130+
- Fixed multiple CVEs in TIFF, RAS, ICO, HDR, PSD, XBM, EXR, JXR plugins.
130131
- Updated jpeg-turbo till v3.1.3
131132
- Updated OpenEXR till v3.4.4
132-
- Updated LibPNG till v1.6.53
133+
- Updated LibPNG till v1.6.54
133134
- Updated LibRaw till v0.21.5
134135
- Updated LibDav1d till v1.5.3
135136

Source/Plugins/PluginRAS.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@
2222
#include "FreeImage.h"
2323
#include "Utilities.h"
2424

25+
#include <cstring>
26+
2527
// ----------------------------------------------------------
2628
// Constants + headers
2729
// ----------------------------------------------------------

Source/Plugins/PluginXBM.cpp

Lines changed: 56 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -25,11 +25,17 @@
2525
#include "FreeImage.h"
2626
#include "Utilities.h"
2727

28+
#include <cstring>
29+
2830
// ==========================================================
2931
// Internal functions
3032
// ==========================================================
3133

32-
#define MAX_LINE 512
34+
#define MAX_LINE 512
35+
#define LINE_FORMAT_WIDTH_OR_HEIGHT "#define %" FI_QUOTE(MAX_LINE) "s %d"
36+
#define LINE_FORMAT_BITS_V10 "static short %" FI_QUOTE(MAX_LINE) "s = {"
37+
#define LINE_FORMAT_BITS_V11_OPT1 "static char %" FI_QUOTE(MAX_LINE) "s = {"
38+
#define LINE_FORMAT_BITS_V11_OPT2 "static unsigned char %" FI_QUOTE(MAX_LINE) "s = {"
3339

3440
static const char *ERR_XBM_SYNTAX = "Syntax error";
3541
static const char *ERR_XBM_LINE = "Line too long";
@@ -87,76 +93,79 @@ Read an XBM file into a buffer
8793
*/
8894
static const char*
8995
readXBMFile(FreeImageIO *io, fi_handle handle, int *widthP, int *heightP, std::unique_ptr<void, decltype(&free)> &dataP) {
90-
char line[MAX_LINE], name_and_type[MAX_LINE];
91-
char *ptr{};
92-
char *t{};
96+
std::string line(MAX_LINE, '\0'), name(MAX_LINE + 1, '\0');
97+
char *ptr{};
9398
int version = 0;
9499
size_t bytes, bytes_per_line, raster_length;
95-
int v, padding;
96100
int c1, c2, value1, value2;
97101
int hex_table[256];
98-
bool found_declaration{}; // haven't found it yet; haven't even looked
102+
bool found_declaration{}; // haven't found it yet; haven't even looked
99103
/* in scanning through the bitmap file, we have found the first
100-
line of the C declaration of the array (the "static char ..."
101-
or whatever line)
104+
line of the C declaration of the array (the "static char ..." or whatever line)
102105
*/
103-
bool eof{}; // we've encountered end of file while searching file
104106

105107
*widthP = *heightP = -1;
106108

107-
while (!found_declaration && !eof) {
109+
for (;;) {
110+
if (!readLine(line.data(), MAX_LINE, io, handle)) {
111+
break;
112+
}
108113

109-
if (!readLine(line, MAX_LINE, io, handle)) {
110-
eof = true;
114+
if (strlen(line.c_str()) >= MAX_LINE - 1) {
115+
return ERR_XBM_LINE;
111116
}
112-
else {
113-
if (strlen(line) == MAX_LINE - 1)
114-
return( ERR_XBM_LINE );
115-
if (sscanf_s(line, "#define %s %d", name_and_type, MAX_LINE, &v) == 2) {
116-
if ((t = strrchr(name_and_type, '_')) == nullptr)
117-
t = name_and_type;
118-
else
119-
t++;
120-
if (!strcmp("width", t))
121-
*widthP = v;
122-
else if (!strcmp("height", t))
123-
*heightP = v;
124-
continue;
125-
}
126117

127-
if (sscanf_s(line, "static short %s = {", name_and_type, MAX_LINE) == 1) {
128-
version = 10;
129-
found_declaration = true;
130-
}
131-
else if (sscanf_s(line, "static char %s = {", name_and_type, MAX_LINE) == 1) {
132-
version = 11;
133-
found_declaration = true;
134-
}
135-
else if (sscanf_s(line, "static unsigned char %s = {", name_and_type, MAX_LINE) == 1) {
136-
version = 11;
137-
found_declaration = true;
118+
int val{};
119+
if (2 == std::sscanf(line.c_str(), LINE_FORMAT_WIDTH_OR_HEIGHT, name.data(), &val)) {
120+
if (const auto suffix = std::strrchr(name.c_str(), '_')) {
121+
if (0 == std::strcmp("_width", suffix)) {
122+
*widthP = val;
123+
continue;
124+
}
125+
if (0 == std::strcmp("_height", suffix)) {
126+
*heightP = val;
127+
continue;
128+
}
138129
}
139130
}
131+
132+
if (1 == std::sscanf(line.c_str(), LINE_FORMAT_BITS_V10, name.data())) {
133+
version = 10;
134+
found_declaration = true;
135+
break;
136+
}
137+
138+
if (1 == std::sscanf(line.c_str(), LINE_FORMAT_BITS_V11_OPT1, name.data()) ||
139+
1 == std::sscanf(line.c_str(), LINE_FORMAT_BITS_V11_OPT2, name.data())) {
140+
version = 11;
141+
found_declaration = true;
142+
break;
143+
}
140144
}
141145

142-
if (!found_declaration)
143-
return( ERR_XBM_DECL );
146+
if (!found_declaration) {
147+
return ERR_XBM_DECL;
148+
}
144149

145-
if (*widthP == -1)
146-
return( ERR_XBM_WIDTH );
147-
if (*heightP == -1)
148-
return( ERR_XBM_HEIGHT );
150+
if (*widthP <= 0) {
151+
return ERR_XBM_WIDTH;
152+
}
153+
if (*heightP <= 0) {
154+
return ERR_XBM_HEIGHT;
155+
}
149156

150-
padding = 0;
151-
if ( ((*widthP % 16) >= 1) && ((*widthP % 16) <= 8) && (version == 10) )
157+
int padding = 0;
158+
if (((*widthP % 16) >= 1) && ((*widthP % 16) <= 8) && (version == 10)) {
152159
padding = 1;
160+
}
153161

154162
bytes_per_line = (*widthP + 7) / 8 + padding;
155163

156164
raster_length = bytes_per_line * *heightP;
157165
dataP.reset(malloc(raster_length));
158-
if (!dataP)
159-
return( ERR_XBM_MEMORY );
166+
if (!dataP) {
167+
return ERR_XBM_MEMORY;
168+
}
160169

161170
// initialize hex_table
162171
for ( c1 = 0; c1 < 256; c1++ ) {

cmake/dependency.dav1d.cmake

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ if (MSVC)
4040
DEPENDEES configure
4141
DEPENDERS build
4242
COMMAND echo "Build Debug"
43-
COMMAND ${MESON_EXECUTABLE} setup ${CMAKE_BINARY_DIR}/dav1d/build_debug --backend vs2022 --buildtype debug
43+
COMMAND ${MESON_EXECUTABLE} setup ${CMAKE_BINARY_DIR}/dav1d/build_debug --backend ${MSVC_NAME} --buildtype debug
4444
--default-library static -Denable_tools=false -Denable_tests=false --prefix ${CMAKE_BINARY_DIR}/dav1d/install
4545
COMMAND ${CMAKE_VS_MSBUILD_COMMAND} ${CMAKE_BINARY_DIR}/dav1d/build_debug/dav1d.sln
4646
COMMAND ${CMAKE_VS_MSBUILD_COMMAND} ${CMAKE_BINARY_DIR}/dav1d/build_debug/RUN_INSTALL.vcxproj

cmake/dependency.heif.cmake

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,11 @@ include(${CMAKE_SOURCE_DIR}/cmake/dependency.kvazaar.cmake)
1111
include(${CMAKE_SOURCE_DIR}/cmake/dependency.dav1d.cmake)
1212
include(${CMAKE_SOURCE_DIR}/cmake/dependency.svtav1.cmake)
1313

14+
set(HEIF_VERSION "1.20.2")
1415

1516
ExternalProject_Add(HEIF
1617
PREFIX ${CMAKE_BINARY_DIR}/heif
17-
URL "https://github.com/strukturag/libheif/releases/download/v1.20.2/libheif-1.20.2.tar.gz"
18+
URL "https://github.com/strukturag/libheif/releases/download/v${HEIF_VERSION}/libheif-${HEIF_VERSION}.tar.gz"
1819
URL_MD5 "5d0442f7197a34b7aaf95bdffabb51e9"
1920
DOWNLOAD_DIR "${CMAKE_SOURCE_DIR}/dependencies/heif"
2021
SOURCE_DIR "${EXTERNALPROJECT_SOURCE_PREFIX}/dependencies/heif/source"
@@ -62,7 +63,7 @@ if (WIN32)
6263
set(LibHEIF_INSTALL_TYPE BIN)
6364
set(LibHEIF_INSTALL_NAME "heif.dll")
6465
else()
65-
set(LibHEIF_INSTALL_LIBRARY ${CMAKE_BINARY_DIR}/heif/install/lib/libheif.so.1.19.7)
66+
set(LibHEIF_INSTALL_LIBRARY ${CMAKE_BINARY_DIR}/heif/install/lib/libheif.so.${HEIF_VERSION})
6667
set(LibHEIF_INSTALL_TYPE LIB)
6768
set(LibHEIF_INSTALL_NAME "libheif.so")
6869
endif()

cmake/dependency.openjph.cmake

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ ExternalProject_Add(OPENJPH
1818
PATCH_COMMAND ""
1919
BUILD_COMMAND ${BUILD_COMMAND_FOR_TARGET} -t openjph
2020
CMAKE_ARGS ${CMAKE_BUILD_TYPE_ARG} "-DBUILD_SHARED_LIBS=OFF" "-DOJPH_BUILD_TESTS=OFF" "-DOJPH_ENABLE_TIFF_SUPPORT=OFF" "-DOJPH_BUILD_EXECUTABLES=OFF"
21-
"-DCMAKE_C_FLAGS:STRING=${ZERO_WARNINGS_FLAG} -fPIC" "-DCMAKE_INSTALL_PREFIX:PATH=${CMAKE_BINARY_DIR}/openjph/install"
21+
"-DCMAKE_C_FLAGS:STRING=${ZERO_WARNINGS_FLAG} -fPIC" "-DCMAKE_DEBUG_POSTFIX=d" "-DCMAKE_INSTALL_PREFIX:PATH=${CMAKE_BINARY_DIR}/openjph/install"
2222
EXCLUDE_FROM_ALL
2323
)
2424

@@ -28,7 +28,11 @@ ExternalProject_Get_Property(OPENJPH INSTALL_DIR)
2828

2929
add_library(LibOpenJPH INTERFACE)
3030
add_dependencies(LibOpenJPH OPENJPH)
31-
link_library_path2(LibOpenJPH ${INSTALL_DIR}/lib ${CMAKE_STATIC_LIBRARY_PREFIX}openjph.0.26${CMAKE_STATIC_LIBRARY_SUFFIX} ${CMAKE_STATIC_LIBRARY_PREFIX}openjph.0.26d${CMAKE_STATIC_LIBRARY_SUFFIX})
31+
if (MSVC)
32+
link_library_path2(LibOpenJPH ${INSTALL_DIR}/lib ${CMAKE_STATIC_LIBRARY_PREFIX}openjph.0.26${CMAKE_STATIC_LIBRARY_SUFFIX} ${CMAKE_STATIC_LIBRARY_PREFIX}openjph.0.26d${CMAKE_STATIC_LIBRARY_SUFFIX})
33+
else()
34+
target_link_libraries(LibOpenJPH INTERFACE ${INSTALL_DIR}/lib/${CMAKE_STATIC_LIBRARY_PREFIX}openjph${CMAKE_STATIC_LIBRARY_SUFFIX})
35+
endif()
3236
target_include_directories(LibOpenJPH INTERFACE ${INSTALL_DIR}/include)
3337
set_property(TARGET OPENJPH PROPERTY FOLDER "Dependencies")
3438

cmake/dependency.png.cmake

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@ unset(INSTALL_DIR)
1212

1313
ExternalProject_Add(PNG
1414
PREFIX ${CMAKE_BINARY_DIR}/png
15-
URL "https://github.com/pnggroup/libpng/archive/refs/tags/v1.6.53.zip"
16-
URL_MD5 "c5405489ce5db36ab2a50799c960f690"
15+
URL "https://github.com/pnggroup/libpng/archive/refs/tags/v1.6.54.zip"
16+
URL_MD5 "1eca555ae2674566a0b988c3ecf2ffaf"
1717
DOWNLOAD_DIR "${CMAKE_SOURCE_DIR}/dependencies/png"
1818
SOURCE_DIR "${EXTERNALPROJECT_SOURCE_PREFIX}/dependencies/png/source"
1919
BINARY_DIR "${CMAKE_BINARY_DIR}/png/build"

0 commit comments

Comments
 (0)