1*f4ee7fbaSAndroid Build Coastguard Worker<p align="center"><img src="https://brotli.org/brotli.svg" alt="Brotli" width="64"></p> 2*f4ee7fbaSAndroid Build Coastguard Worker 3*f4ee7fbaSAndroid Build Coastguard Worker# SECURITY NOTE 4*f4ee7fbaSAndroid Build Coastguard Worker 5*f4ee7fbaSAndroid Build Coastguard WorkerPlease consider updating brotli to version 1.0.9 (latest). 6*f4ee7fbaSAndroid Build Coastguard Worker 7*f4ee7fbaSAndroid Build Coastguard WorkerVersion 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*f4ee7fbaSAndroid Build Coastguard Worker 9*f4ee7fbaSAndroid Build Coastguard Worker### Introduction 10*f4ee7fbaSAndroid Build Coastguard Worker 11*f4ee7fbaSAndroid Build Coastguard WorkerBrotli is a generic-purpose lossless compression algorithm that compresses data 12*f4ee7fbaSAndroid Build Coastguard Workerusing a combination of a modern variant of the LZ77 algorithm, Huffman coding 13*f4ee7fbaSAndroid Build Coastguard Workerand 2nd order context modeling, with a compression ratio comparable to the best 14*f4ee7fbaSAndroid Build Coastguard Workercurrently available general-purpose compression methods. It is similar in speed 15*f4ee7fbaSAndroid Build Coastguard Workerwith deflate but offers more dense compression. 16*f4ee7fbaSAndroid Build Coastguard Worker 17*f4ee7fbaSAndroid Build Coastguard WorkerThe specification of the Brotli Compressed Data Format is defined in [RFC 7932](https://tools.ietf.org/html/rfc7932). 18*f4ee7fbaSAndroid Build Coastguard Worker 19*f4ee7fbaSAndroid Build Coastguard WorkerBrotli is open-sourced under the MIT License, see the LICENSE file. 20*f4ee7fbaSAndroid Build Coastguard Worker 21*f4ee7fbaSAndroid Build Coastguard WorkerBrotli mailing list: 22*f4ee7fbaSAndroid Build Coastguard Workerhttps://groups.google.com/forum/#!forum/brotli 23*f4ee7fbaSAndroid Build Coastguard Worker 24*f4ee7fbaSAndroid Build Coastguard Worker[](https://travis-ci.org/google/brotli) 25*f4ee7fbaSAndroid Build Coastguard Worker[](https://ci.appveyor.com/project/szabadka/brotli) 26*f4ee7fbaSAndroid Build Coastguard Worker[](https://oss-fuzz-build-logs.storage.googleapis.com/index.html#brotli) 27*f4ee7fbaSAndroid Build Coastguard Worker 28*f4ee7fbaSAndroid Build Coastguard Worker### Build instructions 29*f4ee7fbaSAndroid Build Coastguard Worker 30*f4ee7fbaSAndroid Build Coastguard Worker#### Vcpkg 31*f4ee7fbaSAndroid Build Coastguard Worker 32*f4ee7fbaSAndroid Build Coastguard WorkerYou can download and install brotli using the [vcpkg](https://github.com/Microsoft/vcpkg/) dependency manager: 33*f4ee7fbaSAndroid Build Coastguard Worker 34*f4ee7fbaSAndroid Build Coastguard Worker git clone https://github.com/Microsoft/vcpkg.git 35*f4ee7fbaSAndroid Build Coastguard Worker cd vcpkg 36*f4ee7fbaSAndroid Build Coastguard Worker ./bootstrap-vcpkg.sh 37*f4ee7fbaSAndroid Build Coastguard Worker ./vcpkg integrate install 38*f4ee7fbaSAndroid Build Coastguard Worker vcpkg install brotli 39*f4ee7fbaSAndroid Build Coastguard Worker 40*f4ee7fbaSAndroid Build Coastguard WorkerThe 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. 41*f4ee7fbaSAndroid Build Coastguard Worker 42*f4ee7fbaSAndroid Build Coastguard Worker#### Autotools-style CMake 43*f4ee7fbaSAndroid Build Coastguard Worker 44*f4ee7fbaSAndroid Build Coastguard Worker[configure-cmake](https://github.com/nemequ/configure-cmake) is an 45*f4ee7fbaSAndroid Build Coastguard Workerautotools-style configure script for CMake-based projects (not supported on Windows). 46*f4ee7fbaSAndroid Build Coastguard Worker 47*f4ee7fbaSAndroid Build Coastguard WorkerThe basic commands to build, test and install brotli are: 48*f4ee7fbaSAndroid Build Coastguard Worker 49*f4ee7fbaSAndroid Build Coastguard Worker $ mkdir out && cd out 50*f4ee7fbaSAndroid Build Coastguard Worker $ ../configure-cmake 51*f4ee7fbaSAndroid Build Coastguard Worker $ make 52*f4ee7fbaSAndroid Build Coastguard Worker $ make test 53*f4ee7fbaSAndroid Build Coastguard Worker $ make install 54*f4ee7fbaSAndroid Build Coastguard Worker 55*f4ee7fbaSAndroid Build Coastguard WorkerBy default, debug binaries are built. To generate "release" `Makefile` specify `--disable-debug` option to `configure-cmake`. 56*f4ee7fbaSAndroid Build Coastguard Worker 57*f4ee7fbaSAndroid Build Coastguard Worker#### Bazel 58*f4ee7fbaSAndroid Build Coastguard Worker 59*f4ee7fbaSAndroid Build Coastguard WorkerSee [Bazel](http://www.bazel.build/) 60*f4ee7fbaSAndroid Build Coastguard Worker 61*f4ee7fbaSAndroid Build Coastguard Worker#### CMake 62*f4ee7fbaSAndroid Build Coastguard Worker 63*f4ee7fbaSAndroid Build Coastguard WorkerThe basic commands to build and install brotli are: 64*f4ee7fbaSAndroid Build Coastguard Worker 65*f4ee7fbaSAndroid Build Coastguard Worker $ mkdir out && cd out 66*f4ee7fbaSAndroid Build Coastguard Worker $ cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=./installed .. 67*f4ee7fbaSAndroid Build Coastguard Worker $ cmake --build . --config Release --target install 68*f4ee7fbaSAndroid Build Coastguard Worker 69*f4ee7fbaSAndroid Build Coastguard WorkerYou can use other [CMake](https://cmake.org/) configuration. 70*f4ee7fbaSAndroid Build Coastguard Worker 71*f4ee7fbaSAndroid Build Coastguard Worker#### Premake5 72*f4ee7fbaSAndroid Build Coastguard Worker 73*f4ee7fbaSAndroid Build Coastguard WorkerSee [Premake5](https://premake.github.io/) 74*f4ee7fbaSAndroid Build Coastguard Worker 75*f4ee7fbaSAndroid Build Coastguard Worker#### Python 76*f4ee7fbaSAndroid Build Coastguard Worker 77*f4ee7fbaSAndroid Build Coastguard WorkerTo install the latest release of the Python module, run the following: 78*f4ee7fbaSAndroid Build Coastguard Worker 79*f4ee7fbaSAndroid Build Coastguard Worker $ pip install brotli 80*f4ee7fbaSAndroid Build Coastguard Worker 81*f4ee7fbaSAndroid Build Coastguard WorkerTo install the tip-of-the-tree version, run: 82*f4ee7fbaSAndroid Build Coastguard Worker 83*f4ee7fbaSAndroid Build Coastguard Worker $ pip install --upgrade git+https://github.com/google/brotli 84*f4ee7fbaSAndroid Build Coastguard Worker 85*f4ee7fbaSAndroid Build Coastguard WorkerSee the [Python readme](python/README.md) for more details on installing 86*f4ee7fbaSAndroid Build Coastguard Workerfrom source, development, and testing. 87*f4ee7fbaSAndroid Build Coastguard Worker 88*f4ee7fbaSAndroid Build Coastguard Worker### Benchmarks 89*f4ee7fbaSAndroid Build Coastguard Worker* [Squash Compression Benchmark](https://quixdb.github.io/squash-benchmark/) / [Unstable Squash Compression Benchmark](https://quixdb.github.io/squash-benchmark/unstable/) 90*f4ee7fbaSAndroid Build Coastguard Worker* [Large Text Compression Benchmark](http://mattmahoney.net/dc/text.html) 91*f4ee7fbaSAndroid Build Coastguard Worker* [Lzturbo Benchmark](https://sites.google.com/site/powturbo/home/benchmark) 92*f4ee7fbaSAndroid Build Coastguard Worker 93*f4ee7fbaSAndroid Build Coastguard Worker### Related projects 94*f4ee7fbaSAndroid Build Coastguard Worker> **Disclaimer:** Brotli authors take no responsibility for the third party projects mentioned in this section. 95*f4ee7fbaSAndroid Build Coastguard Worker 96*f4ee7fbaSAndroid Build Coastguard WorkerIndependent [decoder](https://github.com/madler/brotli) implementation by Mark Adler, based entirely on format specification. 97*f4ee7fbaSAndroid Build Coastguard Worker 98*f4ee7fbaSAndroid Build Coastguard WorkerJavaScript port of brotli [decoder](https://github.com/devongovett/brotli.js). Could be used directly via `npm install brotli` 99*f4ee7fbaSAndroid Build Coastguard Worker 100*f4ee7fbaSAndroid Build Coastguard WorkerHand ported [decoder / encoder](https://github.com/dominikhlbg/BrotliHaxe) in haxe by Dominik Homberger. Output source code: JavaScript, PHP, Python, Java and C# 101*f4ee7fbaSAndroid Build Coastguard Worker 102*f4ee7fbaSAndroid Build Coastguard Worker7Zip [plugin](https://github.com/mcmilk/7-Zip-Zstd) 103*f4ee7fbaSAndroid Build Coastguard Worker 104*f4ee7fbaSAndroid Build Coastguard WorkerDart [native bindings](https://github.com/thosakwe/brotli) 105