Commit Graph

4801 Commits

Author SHA1 Message Date
Vincent Rabaud
433c7dca11 Fix static analyzer warnings.
Change-Id: I45f0db2310b1188809963af93240e3d438f807b8
2023-09-14 22:43:45 +02:00
James Zern
5fac76cf8d libwebp-1.3.2
- 9/13/2023: version 1.3.2
   This is a binary compatible release.
   * security fix for lossless decoder (chromium: #1479274, CVE-2023-4863)
 -----BEGIN PGP SIGNATURE-----
 
 iQIzBAABCgAdFiEEaw5rcJdt4wPt8vYB+cPWvbgjK10FAmUCZrcACgkQ+cPWvbgj
 K12xQBAAoR6PIMHsttDUvgrCmgM19HbDVYmN3fK1VSL2yhT2Nj71hloIBQ46j+pJ
 aLyOhLX92yvvDEORDvm12LO7e7VwbPxc66Lwh5q0AjgsliMD1sR0yFJHVnZTOrJ/
 ndF0G1dNkrwYYYLWPIDtxrfr2eyB0+el8zjUCkWuKn5WSeaiV3FNfjHmNjQsgf1K
 dyy4DHcmZb5N2eJ6OvsiGvp7JwOjTpoHmYB2TbqfzqbV3Wq/aWgLsuGffpcNiEgP
 i/GCTapAFTdYW7StqXUGWML0IV3E3CrcBYjlWJqR499/DTfX1jrNcyWbuR0iaM9e
 yKlYS4PeylB6xdyEGVNM+8j3Trt3YYxvTGO/ydh9D4CtjaJPzlLfs2646AaV6TFW
 34t9mUDm1ZqQP8yJNqpSF00iwH0LA5/dKTd9Xr/MSifB/nvF3aqQjEDHLeTgD6pS
 D0Kf6OkhBtRuDbw7bTMwTGOZ5Z/VLG9JFni9JPt/KylBANUXQAI8vn0jjZRmpAki
 ketic0AgoDtH1TmPA+AzbiPWxKuFHfH3CpoECsgbpJjuMjbJ7EuXDfiG6cUIqTrD
 Lk+r1jgkCTWikB0KnGxDaNnDx+U0iatH4XfuAqp0o3pEHdgH0p4Gk3Kb8oraSZNv
 Y9AM9TaUaGPZxdyXfyR8glvHSu3li15DF1l1Ewml9qSxuqs/4Ls=
 =Rv7k
 -----END PGP SIGNATURE-----

Merge tag 'v1.3.2'

libwebp-1.3.2

- 9/13/2023: version 1.3.2
  This is a binary compatible release.
  * security fix for lossless decoder (chromium: #1479274, CVE-2023-4863)

* tag 'v1.3.2':
  update ChangeLog
  update NEWS
  bump version to 1.3.2
  Fix OOB write in BuildHuffmanTable.

Bug: webp:620
Change-Id: I094a4fe6ab4f3f8ada6fb662ba9cc6ec0f3bdd87
2023-09-13 19:08:16 -07:00
James Zern
ca332209cb update ChangeLog
Bug: webp:620
Change-Id: I5703f222de7262736339dbfd6ba82f2039dfc850
2023-09-13 15:11:07 -07:00
James Zern
1ace578c91 update NEWS
Bug: webp:620
Change-Id: I393c58cc23ccf98fa3c5d1568f0689a36e64575b
2023-09-13 13:33:58 -07:00
James Zern
63234c4296 bump version to 1.3.2
libwebp{,decoder} - 1.3.2
libwebp libtool - 8.8.1
libwebpdecoder libtool - 4.8.1

mux - 1.3.2
libtool - 3.13.0

demux - 1.3.2
libtool - 2.14.0

sharpyuv - 0.2.1 (no change)
libtool - 0.1.0 (no change)

Bug: webp:620
Change-Id: I9a61d83ee92809de1c2501d1b4fb68aa38f98850
2023-09-13 13:24:49 -07:00
Vincent Rabaud
a35ea50de4 Add a fuzzer for ReadHuffmanCodes
Change-Id: If8c30aaa87c34007ae455a03daa7b3c0f22fc8c3
2023-09-12 23:41:29 +02:00
Vincent Rabaud
95ea5226c8 Fix invalid incremental decoding check.
The first condition is only necessary if we have not read enough
(enough being defined by src_last, not src_end which is the end
of the image).
The second condition now fits the comment below: "if not
incremental, and we are past the end of buffer".

BUG=oss-fuzz:62136

Change-Id: I0700f67c62db8e1c02c2e429a069a71e606a5e4f
2023-09-12 09:22:53 +02:00
Vincent Rabaud
2af26267cd Fix OOB write in BuildHuffmanTable.
First, BuildHuffmanTable is called to check if the data is valid.
If it is and the table is not big enough, more memory is allocated.

This will make sure that valid (but unoptimized because of unbalanced
codes) streams are still decodable.

Bug: chromium:1479274
Change-Id: I31c36dbf3aa78d35ecf38706b50464fd3d375741
(cherry picked from commit 902bc91903)
2023-09-07 15:14:39 -07:00
Vincent Rabaud
902bc91903 Fix OOB write in BuildHuffmanTable.
First, BuildHuffmanTable is called to check if the data is valid.
If it is and the table is not big enough, more memory is allocated.

This will make sure that valid (but unoptimized because of unbalanced
codes) streams are still decodable.

Bug: chromium:1479274
Change-Id: I31c36dbf3aa78d35ecf38706b50464fd3d375741
2023-09-07 21:16:03 +02:00
Vincent Rabaud
7ba44f80f3 Homogenize "__asm__ volatile" vs "asm volatile"
According to https://gcc.gnu.org/onlinedocs/gcc/extensions-to-the-c-language-family/how-to-use-inline-assembly-language-in-c-code.html

For the C language, the asm keyword is a GNU extension. When
writing C code that can be compiled with -ansi and the -std options
that select C dialects without GNU extensions, use __asm__ instead
of asm (see Alternate Keywords). For the C++ language, asm is a
standard keyword, but __asm__ can be used for code compiled with
-fno-asm.

Change-Id: I4af950e67c857c890290c1e3d9cc886da0748784
2023-09-06 17:15:05 +02:00
James Zern
68e271354e webp-container-spec: reorder example chunk layout
place the unknown 'XYZW' chunk at the end of the file to agree with the
order given by the 'Extended File Format' section.

Change-Id: I5cec5a61069a03f3487f5f9ff9209f5ead6de24c
2023-09-01 15:00:53 -07:00
James Zern
943b932a7e Merge changes I6a4d0a04,Ibc37b91e into main
* changes:
  decode.h: wrap idec example in /* */
  decode.h: fix decode example
2023-08-18 00:38:04 +00:00
James Zern
1cc94f9521 decode.h: wrap idec example in /* */
This makes it easier to read and copy/paste, though this is just rough
pseudo-code. It also matches the formatting of the advanced decoder
example.

Change-Id: I6a4d0a04a12bfc1f1956ac965ff4869cefc4f3df
2023-08-15 19:11:50 -07:00
James Zern
63acdd1e06 decode.h: fix decode example
spotted by tsutsui123 at gmail

Bug: webp:615
Change-Id: Ibc37b91e85427b2424b698043a40cce98bae356d
Fixed: webp:615
2023-08-15 19:07:11 -07:00
James Zern
aac5c5d0df ReadHuffmanCode: rm redundant num code lengths check
4 bits are read ([0, 15]) with 4 added to the result. The check that the
result is not > NUM_CODE_LENGTH_CODES (19) is redundant. This makes the
check an assert for documentation purposes.

webp-lossless-bitstream-spec.txt is updated accordingly.

Bug: webp:611
Change-Id: Ie461017dc9de3da4cfe6856543d3dcf58f53a180
2023-08-14 18:07:17 -07:00
James Zern
a2de25f6b6 webp-lossless-bitstream-spec: normalize list item case
In Section 6.2 Details, use uppercase after a :. This is more consistent
with the rest of the doc.

Bug: webp:611
Change-Id: I7ac862c90fd8e5fe0bad0dd5e3515d3095a6dc9a
2023-08-14 17:38:06 -07:00
James Zern
68820f0e53 webp-lossless-bitstream-spec: normalize pixel ref
x, y -> (x, y)

Bug: webp:611
Change-Id: Ic25ae76a9978156e7cd67ad17432ee1a1e172641
2023-08-14 17:38:03 -07:00
James Zern
cdb31aa806 webp-lossless-bitstream-spec: add missing periods
in ordered list in "6.2. Details". This is more consistent with the rest
of the document.

Bug: webp:611
Change-Id: Ie467c771afd5813a30855b24c80cf92673a5281c
2023-08-14 17:37:57 -07:00
James Zern
0535a8cf88 webp-lossless-bitstream-spec: fix grammar
...in same row... -> in the same row

Bug: webp:611
Change-Id: I837ab571084b206cc1a57c534c05cdcd0dfff0fa
2023-08-14 17:37:39 -07:00
James Zern
b6c4ce2635 normalize numbered list item format
from edits made during the RFC AUTH48 process

Change-Id: I82a5d78c0ea611e71927ffb13aa78ccdddfd6dd0
2023-08-09 13:51:38 -07:00
James Zern
dd7364c3ce Merge "palette.c: fix msvc warnings" into main 2023-07-28 20:05:58 +00:00
James Zern
c63c5df618 palette.c: fix msvc warnings
after:
1432ebba Refactor palette sorting computation.

fixes:
src\utils\palette.c(384): warning C4028: formal parameter 2 different
  from declaration
src\utils\palette.c(384): warning C4028: formal parameter 3 different
  from declaration
src\utils\palette.c(384): warning C4028: formal parameter 5 different
  from declaration

Change-Id: If29205f346e674108646045b7a3d90f078fed9b0
2023-07-28 09:07:11 -07:00
James Zern
0a2cad5115 webp-container-spec: move terms from intro section
to 'Terminology & Basics'

Change-Id: Iec9923086a2d339f12025c55da53b1e8a6919380
2023-07-27 16:18:57 -07:00
James Zern
dd88d2ff3e webp-lossless-bitstream-spec: color_cache -> color cache
The text is referring to the color cache, not a variable.

Bug: webp:611
Change-Id: Ife7e8246817ea0831993702bc050ed79998a0ee4
2023-07-27 12:41:04 -07:00
James Zern
6e75054736 Merge changes I644d7d39,Icf05491e,Ic02e6652,I63b11258 into main
* changes:
  webp-lossless-bitstream-spec: fix code blocks
  webp-lossless-bitstream-spec: block -> chunk
  webp-lossless-bitstream-spec: add some missing commas
  webp-lossless-bitstream-spec: normalize item text in 5.1
2023-07-27 19:34:20 +00:00
James Zern
67a7cc2b07 webp-lossless-bitstream-spec: fix code blocks
+ change "> 19" to "greater than 19" as it's referred to in prose

Bug: webp:611
Change-Id: I644d7d39f9c4a19050ff0256114873057aee95ef
2023-07-26 09:42:00 -07:00
Vincent Rabaud
1432ebbadb Refactor palette sorting computation.
This will ease the integration of new methods.

Change-Id: Icec3eddaa4ab9030d28ccfe579eb6dc13ded2f02
2023-07-26 10:25:14 +02:00
James Zern
cd436142f6 webp-lossless-bitstream-spec: block -> chunk
when referring to the RIFF chunk size; this is more consistent with
other documentation.

Bug: webp:611
Change-Id: Icf05491ee79f5c48fab0b4935da397b4e4e45a71
2023-07-25 22:10:06 -07:00
James Zern
3cb66f64b0 webp-lossless-bitstream-spec: add some missing commas
The serial comma change is based on the Chicago Manual of Style
(CMOS), 17th edition.

Bug: webp:611
Change-Id: Ic02e6652662608414c16e0fead2912781a47633d
2023-07-25 22:09:59 -07:00
James Zern
56471a53cf webp-lossless-bitstream-spec: normalize item text in 5.1
Makes references to earlier sections consistent. Based on RFC editor
update.

Bug: webp:611
Change-Id: I63b1125810a3d8afa957d392e98c68a632749d76
2023-07-25 22:08:51 -07:00
James Zern
af7fbfd2d9 vp8l_dec,ReadTransform: improve error status reporting
ExpandColorMap() can fail due to a memory allocation failure.

Found by Nallocfuzz (https://github.com/catenacyber/nallocfuzz).

Change-Id: I868c5db2fee18e876f4aa3b63e744d7297d1a91b
2023-07-21 16:30:50 -07:00
James Zern
7d8e0896e9 vp8l_dec: add VP8LSetError()
similar to VP8SetError(); the first error set takes precedence

Change-Id: Id00eb134cac328f72142a2ec0909e72768a6be0e
2023-07-21 16:30:49 -07:00
James Zern
a71ce1cf74 animencoder_fuzzer: fix error check w/Nallocfuzz
WebPAnimEncoderAdd() may fail due to muxer errors that are reported as
booleans. When running under the nallocfuzz engine, ignore all failures.

Found by Nallocfuzz (https://github.com/catenacyber/nallocfuzz).

Change-Id: I36589545d20ac30a67f7e09264146db085dee6ca
2023-07-21 16:30:48 -07:00
James Zern
e94b36d66d webp-lossless-bitstream-spec: relocate details from 5.1
Move the details given for meta prefix codes and the transforms from
"5.1. Roles of Image Data" to their corresponding sections.

Bug: webp:611
Change-Id: I750a3f45956d0a3928a22113180a2590ac1a36db
2023-07-21 15:50:38 -07:00
James Zern
84628e5611 webp-lossless-bitstream-spec: clarify image width changes
After processing the Color Indexing Transform the image width is
subsampled by the transform's width_bits.

Bug: webp:611
Change-Id: If8d2d47dbe05e5c8085fb3fb4c1b63552be9028b
2023-07-20 17:54:20 -07:00
James Zern
ee72299796 alpha_dec: add missing VP8SetError()
in AllocateAlphaPlane() and VP8DecompressAlphaRows().

Found by Nallocfuzz (https://github.com/catenacyber/nallocfuzz).

Change-Id: I39eb305abfe9f4d7915cce5d91e72917f482bc20
2023-07-18 16:25:29 -07:00
James Zern
0081693d61 enc_dec_fuzzer: use WebPDecode()
rather than WebPDecodeRGBA(). This allows finer grained error detection
and avoids an abort() when running under the nallocfuzz engine.

Change-Id: I8ff37f2fe7e1c8b39bd4a8bfe7b26ac41149ba42
2023-07-18 16:24:11 -07:00
James Zern
0fcb311cfc enc_dec_fuzzer: fix WebPEncode/pic.error_code check
pic.error_code may be set to VP8_ENC_ERROR_BAD_WRITE if the writer fails
due to a memory allocation failure.

Found by Nallocfuzz (https://github.com/catenacyber/nallocfuzz).

Change-Id: I912c9e5f9a37b78832c52d9ab6f0710967fbadac
2023-07-18 16:24:09 -07:00
James Zern
982c177c8a webp-lossless-bitstream-spec: fix struct member refs
remove trailing '_' to match the definition of ColorTransformElement

Bug: webp:611
Change-Id: I741213b389fc88473c72c64090a4733f51d87925
2023-07-14 15:13:27 -07:00
James Zern
56cf562570 webp-lossless-bitstream-spec: use RFC 7405 for ABNF
This allows for case sensitive literals.

Bug: webp:611
Change-Id: I5258c67ab12c48593d433449328fd85d461a05d2
2023-07-14 15:13:27 -07:00
James Zern
6c6b3fd317 webp-lossless-bitstream-spec,cosmetics: delete blank lines
This normalizes the spacing between sections and quiets some lint
warnings.

Bug: webp:611
Change-Id: Ic36eb08d55a566def74f746e2ec225c67ff8aecf
2023-07-14 15:12:35 -07:00
James Zern
29b9eb1517 Merge changes Id56ca4fd,I662bd1d7 into main
* changes:
  webp-lossless-bitstream-spec: add validity note for max_symbol
  webp-lossless-bitstream-spec: fix max_symbol definition
2023-07-13 20:43:51 +00:00
James Zern
47c0af8daf ReadHuffmanCodes: rm max_alphabet_size calc
This is unnecessary as green will have the largest value; the sizes are
currently: 256 + 24 + color_cache_size, 256, 40, in that order.

Change-Id: Ib9ce3292285a7b9c6089557b68a87184b68d17a5
2023-07-12 12:04:57 -07:00
James Zern
b92deba353 animencoder_fuzzer: no WebPAnimEncoderAssemble check w/nallocfuzz
This function may fail due to allocation failures. Use the
NALLOC_FUZZ_VERSION environment variable to detect the engine. This was
added in:
9c9a9883cc

Change-Id: Ia5b6fd9458ffa1f810152a10ab49a48c75d17687
2023-07-10 15:10:00 -07:00
James Zern
6be9bf8bae animencoder_fuzzer: fix leak on alloc failure
Change-Id: Id626145a336fc33c4a4158719957f3c96db156c8
2023-07-10 15:09:17 -07:00
James Zern
5c965e55dd vp8l_dec,cosmetics: add some /*param=*/ comments
Change-Id: I8912a5d8a8f550517e644e1af6b468b49505247f
2023-07-07 19:57:47 -07:00
James Zern
e4fc2f78c7 webp-lossless-bitstream-spec: add validity note for max_symbol
Bug: webp:611
Change-Id: Id56ca4fd0ad3cfc17c9c971281ccfb8ce7eaa2f4
2023-07-07 15:54:34 -07:00
James Zern
71916726b6 webp-lossless-bitstream-spec: fix max_symbol definition
If ReadBits(0) == 0, the value of max_symbol is set to the alphabet size
for each symbol type.

See vp8l_dec.c, ReadHuffmanCode(), which passes alphabet_size to
ReadHuffmanCodeLengths() as num_symbols, and ReadHuffmanCodeLengths()
then sets max_symbol to that.

Bug: webp:611
Change-Id: I662bd1d7f372e7f2e9c71cc86f87aefd02f36647
2023-07-07 15:54:34 -07:00
Vincent Rabaud
eac3bd5c53 Have the palette code be in its own file.
Change-Id: I099a342effedd9f451c94d00a14aead27079e6cc
2023-07-06 22:09:24 +02:00
Vincent Rabaud
e2c85878f6 Add an initializer for the SharpYuvOptions struct.
Change-Id: I36510bc361b040d3d3e7d261ab67b24ffc3013a6
2023-07-01 21:15:37 +02:00