Skip to content

Commit 0bc8a71

Browse files
committed
Merge branch 'brotli-1.1.0': Update brotli to version 1.0.9;
closes gh-359
2 parents 0e3de9b + 09a7c23 commit 0bc8a71

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

86 files changed

+4791
-1621
lines changed

C/brotli/Brotli-Adjust.sh

+32-22
Original file line numberDiff line numberDiff line change
@@ -8,41 +8,51 @@ chmod +x $0
88

99
mv include/brotli/* .
1010
rm -rf include
11-
for i in */*.c *.h; do
12-
sed -i 's|<brotli/port.h>|"port.h"|g' "$i"
13-
sed -i 's|<brotli/types.h>|"types.h"|g' "$i"
14-
sed -i 's|<brotli/encode.h>|"encode.h"|g' "$i"
15-
sed -i 's|<brotli/decode.h>|"decode.h"|g' "$i"
16-
done
17-
for i in */*.h; do
18-
sed -i 's|<brotli/port.h>|"../port.h"|g' "$i"
19-
sed -i 's|<brotli/types.h>|"../types.h"|g' "$i"
20-
sed -i 's|<brotli/encode.h>|"../encode.h"|g' "$i"
21-
sed -i 's|<brotli/decode.h>|"../decode.h"|g' "$i"
22-
done
2311

2412
cd common
2513
sed -i 's|include "./|include "./common/|g' *.c
14+
sed -i 's|include "\([a-z]\)|include "./common/\1|g' *.c
2615
for f in *.c; do mv $f ../br_$f; done
2716

2817
cd ../dec
2918
sed -i 's|include "./|include "./dec/|g' *.c
19+
sed -i 's|include "\([a-z]\)|include "./dec/\1|g' *.c
3020
sed -i 's|include "../common|include "./common|g' *.c
3121
for f in *.c; do mv $f ../br_$f; done
3222

3323
cd ../enc
3424
sed -i 's|include "./|include "./enc/|g' *.c
25+
sed -i 's|include "\([a-z]\)|include "./enc/\1|g' *.c
3526
sed -i 's|include "../common|include "./common/|g' *.c
3627
for f in *.c; do mv $f ../br_$f; done
3728

38-
exit
39-
40-
# then put these to "port.h"
29+
cd ../
30+
for i in *.c *.h; do
31+
sed -i 's|<brotli/port.h>|"port.h"|g' "$i"
32+
sed -i 's|<brotli/types.h>|"types.h"|g' "$i"
33+
sed -i 's|<brotli/encode.h>|"encode.h"|g' "$i"
34+
sed -i 's|<brotli/decode.h>|"decode.h"|g' "$i"
35+
sed -i 's|<brotli/shared_dictionary.h>|"shared_dictionary.h"|g' "$i"
36+
37+
done
38+
for i in */*.h; do
39+
sed -i 's|<brotli/port.h>|"../port.h"|g' "$i"
40+
sed -i 's|<brotli/types.h>|"../types.h"|g' "$i"
41+
sed -i 's|<brotli/encode.h>|"../encode.h"|g' "$i"
42+
sed -i 's|<brotli/decode.h>|"../decode.h"|g' "$i"
43+
sed -i 's|<brotli/shared_dictionary.h>|"../shared_dictionary.h"|g' "$i"
44+
done
4145

42-
/* disable some warnings /TR */
43-
#pragma warning(disable : 4100)
44-
#pragma warning(disable : 4127)
45-
#pragma warning(disable : 4189)
46-
#pragma warning(disable : 4295)
47-
#pragma warning(disable : 4389)
48-
#pragma warning(disable : 4701)
46+
git add --renormalize .
47+
48+
sed -i 's|#define BROTLI_COMMON_PORT_H_|#define BROTLI_COMMON_PORT_H_\
49+
\
50+
/* disable some warnings /TR */\
51+
#pragma warning(disable : 4100)\
52+
#pragma warning(disable : 4127)\
53+
#pragma warning(disable : 4189)\
54+
#pragma warning(disable : 4201)\
55+
#pragma warning(disable : 4295)\
56+
#pragma warning(disable : 4334)\
57+
#pragma warning(disable : 4389)\
58+
#pragma warning(disable : 4701)|' 'port.h'

C/brotli/README.md

+23-32
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,9 @@
1+
<p align="center">
2+
<img src="https://github.com/google/brotli/actions/workflows/build_test.yml/badge.svg" alt="GitHub Actions Build Status" href="https://github.com/google/brotli/actions?query=branch%3Amaster">
3+
<img src="https://oss-fuzz-build-logs.storage.googleapis.com/badges/brotli.svg" alt="Fuzzing Status" href="https://oss-fuzz-build-logs.storage.googleapis.com/index.html#brotli">
4+
</p>
15
<p align="center"><img src="https://brotli.org/brotli.svg" alt="Brotli" width="64"></p>
26

3-
# SECURITY NOTE
4-
5-
Please consider updating brotli to version 1.0.9 (latest).
6-
7-
Version 1.0.9 contains a fix to "integer overflow" problem. This happens when "one-shot" decoding API is used (or input chunk for streaming API is not limited), input size (chunk size) is larger than 2GiB, and input contains uncompressed blocks. After the overflow happens, `memcpy` is invoked with a gigantic `num` value, that will likely cause the crash.
8-
97
### Introduction
108

119
Brotli is a generic-purpose lossless compression algorithm that compresses data
@@ -18,12 +16,10 @@ The specification of the Brotli Compressed Data Format is defined in [RFC 7932](
1816

1917
Brotli is open-sourced under the MIT License, see the LICENSE file.
2018

21-
Brotli mailing list:
22-
https://groups.google.com/forum/#!forum/brotli
23-
24-
[![TravisCI Build Status](https://travis-ci.org/google/brotli.svg?branch=master)](https://travis-ci.org/google/brotli)
25-
[![AppVeyor Build Status](https://ci.appveyor.com/api/projects/status/github/google/brotli?branch=master&svg=true)](https://ci.appveyor.com/project/szabadka/brotli)
26-
[![Fuzzing Status](https://oss-fuzz-build-logs.storage.googleapis.com/badges/brotli.svg)](https://oss-fuzz-build-logs.storage.googleapis.com/index.html#brotli)
19+
> **Please note:** brotli is a "stream" format; it does not contain
20+
> meta-information, like checksums or uncompresssed data length. It is possible
21+
> to modify "raw" ranges of the compressed stream and the decoder will not
22+
> notice that.
2723
2824
### Build instructions
2925

@@ -35,25 +31,10 @@ You can download and install brotli using the [vcpkg](https://github.com/Microso
3531
cd vcpkg
3632
./bootstrap-vcpkg.sh
3733
./vcpkg integrate install
38-
vcpkg install brotli
34+
./vcpkg install brotli
3935

4036
The brotli port in vcpkg is kept up to date by Microsoft team members and community contributors. If the version is out of date, please [create an issue or pull request](https://github.com/Microsoft/vcpkg) on the vcpkg repository.
4137

42-
#### Autotools-style CMake
43-
44-
[configure-cmake](https://github.com/nemequ/configure-cmake) is an
45-
autotools-style configure script for CMake-based projects (not supported on Windows).
46-
47-
The basic commands to build, test and install brotli are:
48-
49-
$ mkdir out && cd out
50-
$ ../configure-cmake
51-
$ make
52-
$ make test
53-
$ make install
54-
55-
By default, debug binaries are built. To generate "release" `Makefile` specify `--disable-debug` option to `configure-cmake`.
56-
5738
#### Bazel
5839

5940
See [Bazel](http://www.bazel.build/)
@@ -68,10 +49,6 @@ The basic commands to build and install brotli are:
6849

6950
You can use other [CMake](https://cmake.org/) configuration.
7051

71-
#### Premake5
72-
73-
See [Premake5](https://premake.github.io/)
74-
7552
#### Python
7653

7754
To install the latest release of the Python module, run the following:
@@ -85,6 +62,18 @@ To install the tip-of-the-tree version, run:
8562
See the [Python readme](python/README.md) for more details on installing
8663
from source, development, and testing.
8764

65+
### Contributing
66+
67+
We glad to answer/library related questions in
68+
[brotli mailing list](https://groups.google.com/forum/#!forum/brotli).
69+
70+
Regular issues / feature requests should be reported in
71+
[issue tracker](https://github.com/google/brotli/issues).
72+
73+
For reporting vulnerability please read [SECURITY](SECURITY.md).
74+
75+
For contributing changes please read [CONTRIBUTING](CONTRIBUTING.md).
76+
8877
### Benchmarks
8978
* [Squash Compression Benchmark](https://quixdb.github.io/squash-benchmark/) / [Unstable Squash Compression Benchmark](https://quixdb.github.io/squash-benchmark/unstable/)
9079
* [Large Text Compression Benchmark](http://mattmahoney.net/dc/text.html)
@@ -102,3 +91,5 @@ Hand ported [decoder / encoder](https://github.com/dominikhlbg/BrotliHaxe) in ha
10291
7Zip [plugin](https://github.com/mcmilk/7-Zip-Zstd)
10392

10493
Dart [native bindings](https://github.com/thosakwe/brotli)
94+
95+
Dart compression framework with [fast FFI-based Brotli implementation](https://pub.dev/documentation/es_compression/latest/brotli/brotli-library.html) with ready-to-use prebuilt binaries for Win/Linux/Mac

C/brotli/br_backward_references.c

+64-2
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,15 @@
88

99
#include "./enc/backward_references.h"
1010

11+
#include "types.h"
12+
1113
#include "./common//constants.h"
12-
#include "./common//context.h"
1314
#include "./common//dictionary.h"
1415
#include "./common//platform.h"
15-
#include "types.h"
1616
#include "./enc/command.h"
17+
#include "./enc/compound_dictionary.h"
1718
#include "./enc/dictionary_hash.h"
19+
#include "./enc/encoder_dict.h"
1820
#include "./enc/memory.h"
1921
#include "./enc/quality.h"
2022

@@ -52,6 +54,7 @@ static BROTLI_INLINE size_t ComputeDistanceCode(size_t distance,
5254
#define EXPORT_FN(X) EXPAND_CAT(X, EXPAND_CAT(PREFIX(), HASHER()))
5355

5456
#define PREFIX() N
57+
#define ENABLE_COMPOUND_DICTIONARY 0
5558

5659
#define HASHER() H2
5760
/* NOLINTNEXTLINE(build/include) */
@@ -113,6 +116,41 @@ static BROTLI_INLINE size_t ComputeDistanceCode(size_t distance,
113116
#include "./enc/backward_references_inc.h"
114117
#undef HASHER
115118

119+
#undef ENABLE_COMPOUND_DICTIONARY
120+
#undef PREFIX
121+
#define PREFIX() D
122+
#define ENABLE_COMPOUND_DICTIONARY 1
123+
124+
#define HASHER() H5
125+
/* NOLINTNEXTLINE(build/include) */
126+
#include "./enc/backward_references_inc.h"
127+
#undef HASHER
128+
#define HASHER() H6
129+
/* NOLINTNEXTLINE(build/include) */
130+
#include "./enc/backward_references_inc.h"
131+
#undef HASHER
132+
#define HASHER() H40
133+
/* NOLINTNEXTLINE(build/include) */
134+
#include "./enc/backward_references_inc.h"
135+
#undef HASHER
136+
#define HASHER() H41
137+
/* NOLINTNEXTLINE(build/include) */
138+
#include "./enc/backward_references_inc.h"
139+
#undef HASHER
140+
#define HASHER() H42
141+
/* NOLINTNEXTLINE(build/include) */
142+
#include "./enc/backward_references_inc.h"
143+
#undef HASHER
144+
#define HASHER() H55
145+
/* NOLINTNEXTLINE(build/include) */
146+
#include "./enc/backward_references_inc.h"
147+
#undef HASHER
148+
#define HASHER() H65
149+
/* NOLINTNEXTLINE(build/include) */
150+
#include "./enc/backward_references_inc.h"
151+
#undef HASHER
152+
153+
#undef ENABLE_COMPOUND_DICTIONARY
116154
#undef PREFIX
117155

118156
#undef EXPORT_FN
@@ -125,6 +163,29 @@ void BrotliCreateBackwardReferences(size_t num_bytes,
125163
ContextLut literal_context_lut, const BrotliEncoderParams* params,
126164
Hasher* hasher, int* dist_cache, size_t* last_insert_len,
127165
Command* commands, size_t* num_commands, size_t* num_literals) {
166+
if (params->dictionary.compound.num_chunks != 0) {
167+
switch (params->hasher.type) {
168+
#define CASE_(N) \
169+
case N: \
170+
CreateBackwardReferencesDH ## N(num_bytes, \
171+
position, ringbuffer, ringbuffer_mask, \
172+
literal_context_lut, params, hasher, dist_cache, \
173+
last_insert_len, commands, num_commands, num_literals); \
174+
return;
175+
CASE_(5)
176+
CASE_(6)
177+
CASE_(40)
178+
CASE_(41)
179+
CASE_(42)
180+
CASE_(55)
181+
CASE_(65)
182+
#undef CASE_
183+
default:
184+
BROTLI_DCHECK(false);
185+
break;
186+
}
187+
}
188+
128189
switch (params->hasher.type) {
129190
#define CASE_(N) \
130191
case N: \
@@ -136,6 +197,7 @@ void BrotliCreateBackwardReferences(size_t num_bytes,
136197
FOR_GENERIC_HASHERS(CASE_)
137198
#undef CASE_
138199
default:
200+
BROTLI_DCHECK(false);
139201
break;
140202
}
141203
}

0 commit comments

Comments
 (0)