From d9a505ffb6b4c98677ea30803f17cad6ec1395ce Mon Sep 17 00:00:00 2001 From: James Zern Date: Tue, 17 Jan 2023 18:22:47 -0800 Subject: CMakeLists.txt: allow CMAKE_INSTALL_RPATH to be set empty this allows the user to override the default non-empty value added in: b4994eaa CMake: set rpath for shared objects Bug: webp:592 Change-Id: I069dcbcd8c2f1e8654d9bc98149139f398ac2c93 Fixed: webp:592 --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 0a5af428..f378db5b 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -101,7 +101,7 @@ endif() include(cmake/deps.cmake) include(GNUInstallDirs) -if(BUILD_SHARED_LIBS AND NOT CMAKE_INSTALL_RPATH) +if(BUILD_SHARED_LIBS AND NOT DEFINED CMAKE_INSTALL_RPATH) # Set the rpath to match autoconf/libtool behavior. Note this must be set # before target creation. set(CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBDIR}") -- cgit v1.2.3 From 31c28db53c6fa3be7026212fdd1526280e3f0f52 Mon Sep 17 00:00:00 2001 From: James Zern Date: Tue, 17 Jan 2023 18:27:00 -0800 Subject: libwebp{,demux,mux}.pc.in: Requires -> Requires.private The libraries don't expose the symbols in libsharpyuv / libwebp, they're only needed when static linking. Noted for libwebp (Requires: libsharpyuv) in: https://crbug.com/webp/590#c5. libwebpdemux and libwebpmux had a similar issue with libwebp. See also: https://web.archive.org/web/20190921014607/https://wiki.openmandriva.org/en/Overlinking_issues_in_packaging Change-Id: Ia1866b6b44cbb1ef1a77fd45fbcf10c027eae788 --- src/demux/libwebpdemux.pc.in | 2 +- src/libwebp.pc.in | 2 +- src/mux/libwebpmux.pc.in | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/demux/libwebpdemux.pc.in b/src/demux/libwebpdemux.pc.in index 15ed1763..4da2e40a 100644 --- a/src/demux/libwebpdemux.pc.in +++ b/src/demux/libwebpdemux.pc.in @@ -6,6 +6,6 @@ includedir=@includedir@ Name: libwebpdemux Description: Library for parsing the WebP graphics format container Version: @PACKAGE_VERSION@ -Requires: libwebp >= 0.2.0 +Requires.private: libwebp >= 0.2.0 Cflags: -I${includedir} Libs: -L${libdir} -l@webp_libname_prefix@webpdemux diff --git a/src/libwebp.pc.in b/src/libwebp.pc.in index a755b54e..783090ef 100644 --- a/src/libwebp.pc.in +++ b/src/libwebp.pc.in @@ -6,7 +6,7 @@ includedir=@includedir@ Name: libwebp Description: Library for the WebP graphics format Version: @PACKAGE_VERSION@ -Requires: libsharpyuv +Requires.private: libsharpyuv Cflags: -I${includedir} Libs: -L${libdir} -l@webp_libname_prefix@webp Libs.private: -lm @PTHREAD_CFLAGS@ @PTHREAD_LIBS@ diff --git a/src/mux/libwebpmux.pc.in b/src/mux/libwebpmux.pc.in index 9d4d6e1e..c770daaf 100644 --- a/src/mux/libwebpmux.pc.in +++ b/src/mux/libwebpmux.pc.in @@ -6,7 +6,7 @@ includedir=@includedir@ Name: libwebpmux Description: Library for manipulating the WebP graphics format container Version: @PACKAGE_VERSION@ -Requires: libwebp >= 0.2.0 +Requires.private: libwebp >= 0.2.0 Cflags: -I${includedir} Libs: -L${libdir} -l@webp_libname_prefix@webpmux Libs.private: -lm -- cgit v1.2.3 From 7361842839ebec7e95e30d15172d6b21d9e2403b Mon Sep 17 00:00:00 2001 From: Yannis Guyon Date: Fri, 27 Jan 2023 14:39:14 +0100 Subject: Limit scaling in libwebp advanced_api_fuzzer.c Change-Id: Ic1e3fdc76f4bdcb1ac68cf4f9334d2e77ca29374 --- tests/fuzzer/advanced_api_fuzzer.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/tests/fuzzer/advanced_api_fuzzer.c b/tests/fuzzer/advanced_api_fuzzer.c index a5323e4d..ab183b1c 100644 --- a/tests/fuzzer/advanced_api_fuzzer.c +++ b/tests/fuzzer/advanced_api_fuzzer.c @@ -69,9 +69,14 @@ int LLVMFuzzerTestOneInput(const uint8_t* const data, size_t size) { // files prepended with sizeof(config.options) zeroes to allow the fuzzer // to modify these independently. const int data_offset = 50; - if (size > data_offset + sizeof(config.options)) { - memcpy(&config.options, data + data_offset, sizeof(config.options)); - } else { + if (data_offset + sizeof(config.options) >= size) break; + memcpy(&config.options, data + data_offset, sizeof(config.options)); + + // Skip easily avoidable out-of-memory fuzzing errors. + if (config.options.use_scaling && config.options.scaled_width > 0 && + config.options.scaled_height > 0 && + (size_t)config.options.scaled_width * config.options.scaled_height > + kFuzzPxLimit) { break; } } -- cgit v1.2.3 From 52b6f0670381917161e3d7089f5b0ab5f13acbf1 Mon Sep 17 00:00:00 2001 From: Yannis Guyon Date: Tue, 7 Feb 2023 17:59:00 +0100 Subject: Fix scaling limit in advanced_api_fuzzer.c config.options.scaled_width or config.options.scaled_height being 0 means a ratio-conservative scaling so 7361842 was not enough. Change-Id: Ib75241eb683cf824bc46222c5c07535b6c6d7313 --- tests/fuzzer/advanced_api_fuzzer.c | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/tests/fuzzer/advanced_api_fuzzer.c b/tests/fuzzer/advanced_api_fuzzer.c index ab183b1c..291d0c03 100644 --- a/tests/fuzzer/advanced_api_fuzzer.c +++ b/tests/fuzzer/advanced_api_fuzzer.c @@ -14,9 +14,11 @@ // //////////////////////////////////////////////////////////////////////////////// +#include #include #include "./fuzz_utils.h" +#include "src/utils/rescaler_utils.h" #include "src/webp/decode.h" int LLVMFuzzerTestOneInput(const uint8_t* const data, size_t size) { @@ -73,11 +75,15 @@ int LLVMFuzzerTestOneInput(const uint8_t* const data, size_t size) { memcpy(&config.options, data + data_offset, sizeof(config.options)); // Skip easily avoidable out-of-memory fuzzing errors. - if (config.options.use_scaling && config.options.scaled_width > 0 && - config.options.scaled_height > 0 && - (size_t)config.options.scaled_width * config.options.scaled_height > - kFuzzPxLimit) { - break; + if (config.options.use_scaling) { + int scaled_width = config.options.scaled_width; + int scaled_height = config.options.scaled_height; + if (WebPRescalerGetScaledDimensions(config.input.width, + config.input.height, &scaled_width, + &scaled_height) && + (uint64_t)scaled_width * scaled_height > kFuzzPxLimit) { + break; + } } } if (size % 3) { -- cgit v1.2.3 From 1347a32d82276ecf4daba12f6e9142cc4e1f2401 Mon Sep 17 00:00:00 2001 From: Yannis Guyon Date: Wed, 8 Feb 2023 10:53:40 +0100 Subject: Skip big scaled advanced_api_fuzzer To avoid timeouts. Change-Id: I8f04fd45313bef47004a616d2460be992692030d --- tests/fuzzer/advanced_api_fuzzer.c | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) diff --git a/tests/fuzzer/advanced_api_fuzzer.c b/tests/fuzzer/advanced_api_fuzzer.c index 291d0c03..1378d0bc 100644 --- a/tests/fuzzer/advanced_api_fuzzer.c +++ b/tests/fuzzer/advanced_api_fuzzer.c @@ -22,7 +22,6 @@ #include "src/webp/decode.h" int LLVMFuzzerTestOneInput(const uint8_t* const data, size_t size) { - int i; WebPDecoderConfig config; if (!WebPInitDecoderConfig(&config)) return 0; if (WebPGetFeatures(data, size, &config.input) != VP8_STATUS_OK) return 0; @@ -64,7 +63,7 @@ int LLVMFuzzerTestOneInput(const uint8_t* const data, size_t size) { config.output.colorspace = (WEBP_CSP_MODE)(value % MODE_LAST); #endif // WEBP_REDUCE_CSP - for (i = 0; i < 2; ++i) { + for (int i = 0; i < 2; ++i) { if (i == 1) { // Use the bitstream data to generate extreme ranges for the options. An // alternative approach would be to use a custom corpus containing webp @@ -80,9 +79,21 @@ int LLVMFuzzerTestOneInput(const uint8_t* const data, size_t size) { int scaled_height = config.options.scaled_height; if (WebPRescalerGetScaledDimensions(config.input.width, config.input.height, &scaled_width, - &scaled_height) && - (uint64_t)scaled_width * scaled_height > kFuzzPxLimit) { - break; + &scaled_height)) { + size_t fuzz_px_limit = kFuzzPxLimit; + if (scaled_width != config.input.width || + scaled_height != config.input.height) { + // Using the WebPRescalerImport internally can significantly slow + // down the execution. Avoid timeouts due to that. + fuzz_px_limit /= 2; + } + // A big output canvas can lead to out-of-memory and timeout issues, + // but a big internal working buffer can too. + if ((uint64_t)scaled_width * scaled_height > fuzz_px_limit || + (uint64_t)config.input.width * config.input.height > + fuzz_px_limit) { + break; + } } } } -- cgit v1.2.3 From a486d800b60d0af4cc0836bf7ed8f21e12974129 Mon Sep 17 00:00:00 2001 From: James Zern Date: Wed, 22 Feb 2023 22:15:47 -0800 Subject: EncodeAlphaInternal: clear result->bw on error This avoids a double free should the function fail prior to VP8BitWriterInit() and a previous trial result's buffer carried over. Previously in ApplyFiltersAndEncode() trial.bw (with a previous iteration's buffer) would be freed, followed by best.bw pointing to the same buffer. Since: 187d379d add a fallback to ALPHA_NO_COMPRESSION In addition, check the return value of VP8BitWriterInit() in this function. Bug: webp:603 Change-Id: Ic258381ee26c8c16bc211d157c8153831c8c6910 --- src/enc/alpha_enc.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/enc/alpha_enc.c b/src/enc/alpha_enc.c index f7c02690..7d205586 100644 --- a/src/enc/alpha_enc.c +++ b/src/enc/alpha_enc.c @@ -13,6 +13,7 @@ #include #include +#include #include "src/enc/vp8i_enc.h" #include "src/dsp/dsp.h" @@ -148,6 +149,7 @@ static int EncodeAlphaInternal(const uint8_t* const data, int width, int height, } } else { VP8LBitWriterWipeOut(&tmp_bw); + memset(&result->bw, 0, sizeof(result->bw)); return 0; } } @@ -162,7 +164,7 @@ static int EncodeAlphaInternal(const uint8_t* const data, int width, int height, header = method | (filter << 2); if (reduce_levels) header |= ALPHA_PREPROCESSED_LEVELS << 4; - VP8BitWriterInit(&result->bw, ALPHA_HEADER_LEN + output_size); + if (!VP8BitWriterInit(&result->bw, ALPHA_HEADER_LEN + output_size)) ok = 0; ok = ok && VP8BitWriterAppend(&result->bw, &header, ALPHA_HEADER_LEN); ok = ok && VP8BitWriterAppend(&result->bw, output, output_size); -- cgit v1.2.3 From 2d9d9265f59dfc563c623e9e4352142b35422727 Mon Sep 17 00:00:00 2001 From: Thiago Perrotta Date: Thu, 23 Feb 2023 18:10:40 -0500 Subject: Update yapf style from "chromium" to "yapf" yapf v0.30.0 renamed "chromium" style to "yapf". Bug: chromium:1306598 Change-Id: I2a637d2c5d64f81ba411b1c0d07339ad7480bd66 --- .style.yapf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.style.yapf b/.style.yapf index 47ca4cce..0be981a4 100644 --- a/.style.yapf +++ b/.style.yapf @@ -1,2 +1,2 @@ [style] -based_on_style = chromium \ No newline at end of file +based_on_style = yapf \ No newline at end of file -- cgit v1.2.3 From 0edbb6ea7176eca19955be701178fa70ecb497ee Mon Sep 17 00:00:00 2001 From: James Zern Date: Thu, 23 Feb 2023 22:01:20 -0800 Subject: PaletteSortModifiedZeng: fix leak on error Change-Id: I462bd9a3bc4670efdf251c295f6771a38c08a6ce --- src/enc/vp8l_enc.c | 1 + 1 file changed, 1 insertion(+) diff --git a/src/enc/vp8l_enc.c b/src/enc/vp8l_enc.c index 0b07e529..cb5549af 100644 --- a/src/enc/vp8l_enc.c +++ b/src/enc/vp8l_enc.c @@ -259,6 +259,7 @@ static int PaletteSortModifiedZeng( return 0; } if (!CoOccurrenceBuild(pic, palette_sorted, num_colors, cooccurrence)) { + WebPSafeFree(cooccurrence); return 0; } -- cgit v1.2.3