Initialize for brotli

This commit is contained in:
zyppe 2024-02-09 18:51:09 +08:00
commit da409115fb
8 changed files with 2924 additions and 0 deletions

1
.brotli.metadata Normal file
View file

@ -0,0 +1 @@
9da1ca42a5c375b8998260879f7b53158169cbb45815392db275a4d6f566b08e brotli-1.0.7.tar.gz

1
.gitignore vendored Normal file
View file

@ -0,0 +1 @@
brotli-1.0.7.tar.gz

4
baselibs.conf Normal file
View file

@ -0,0 +1,4 @@
libbrotlicommon1
libbrotlidec1
libbrotlienc1

114
brotli.changes Normal file
View file

@ -0,0 +1,114 @@
* Fri Nov 26 2021 danilo.spinella@suse.com
- Fix CVE-2020-8927, decoder: integer overflow when input chunk
is larger than 2GiB. (CVE-2020-8927, bsc#1175825)
* fix-cve-2020-8927.patch
* Sun Jan 13 2019 bjorn.lie@gmail.com
- Add brotli_Verbose-CLI+Shared-Brotli.patch: Verbose CLI + start
pulling "Shared-Brotli".
* verbose CLI output; fix gh#google/brotlie#666.
* pull `SHIFT` transforms; currently this is semantically dead
code; later it will be used by "Shared-Brotli".
- Add brotli_Ensure-decompression-consumes-all-input.patch: Ensure
decompression consumes all input. If not, it's a corrupt stream.
- Tweak spec slightly.
* Fri Dec 14 2018 jengelh@inai.de
- Avoid bashisms, install manpages without +x bit, get rid of
wrap descriptions, feed through cleaner.
* Fri Dec 14 2018 astieger@suse.com
- brotli 1.0.7:
* faster decoding on ARM
* improved precision of window size calculation in CLI
- includes changes from 1.0.6:
* fix unaligned 64-bit accesses on AArch32
* add ASAN/MSAN unaligned read specializations
* fix JDK 8<->9 incompatibility
* Wed Jul 25 2018 bjorn.lie@gmail.com
- Add baselibs.conf, build 32bit library support.
* Tue Jul 24 2018 mpluskal@suse.com
- Use cmake macros for building and tests
* Thu Jun 28 2018 mpluskal@suse.com
- Update to version 1.0.5:
* improve q=1 compression on small files
* inverse Bazel workspace tree
* add rolling-composite-hasher for large-window mode
* add tools to download and transform static dictionary data
- Changes for version 1.0.4:
* fix unaligned access for aarch64-cross-armhf build
* fix aarch64 target detection
* allow CLI to compress with enabled "large window" feature
* add NPOSTFIX / NDIRECT encoder parameters
* automatic NDIRECT/NPOSTFIX tuning (better compression)
* fix "memory leak" in python tests
* fix bug in durchschlag
* fix source file lists (add params.h)
* fix Bazel/MSVC compilator options
* fix "fall though" warnings
* Wed May 2 2018 bjorn.lie@gmail.com
- Add missing libbrotlicommon%%%%{sover} and libbrotlidec%%%%{sover}
Requires to devel subpackage.
* Mon Mar 5 2018 jengelh@inai.de
- Update to new upstream release 1.0.3
* New "Large Window Brotli" feature
* New dictionary generator
* Wed Jan 3 2018 jengelh@inai.de
- Merge devel subpackages as libbrotli-devel
* Sat Dec 30 2017 jengelh@inai.de
- Avoid shipping duplicate files.
Avoid shipping README.md, this just contains the description -
and build instructions.
- Drop duplicate Requires on -devel.
* Wed Dec 20 2017 pgajdos@suse.com
- build for SLE_12 and SLE_12_SP1
* Thu Nov 30 2017 buschmann23@opensuse.org
- update to Brotli 1.0.2
+ Major chnages
* added Autotools build files
* switched shared library version to libtool scheme
+ Minor changes
* BrotliDictionary members are not const now
* ZopfliNode distance could be up to 128MiB
* fixed API documentation typos
* total_out is always set by decoder
* fixed BROTLI_ENSURE_CAPACITY macro; no-op in preprocessed output
+ Other changes
* fixed scripts for oss-fuzz, test them with Travis
* made Bazel JNI tests less messy
* fixed linter warnings in JS decoder
* fixed permissions of various files
* added Bazel build to Appveyor matrix
* added Sieve dictionary generator
* Tue Oct 24 2017 buschmann23@opensuse.org
- update to Brotli 1.0.1
+ updated README.md
+ fixed parallel exeuction of CMake "compatibility" tests
- update to Brotli 1.0.0
+ new CLI; bro -> brotli; + man page
+ remove "custom dictionary" support
+ add ability to side-load brotli RFC dictionary
+ add decoder API to avoid ringbuffer reallocation
+ PY streaming decompression support
+ PY wrapper accepts memview
- spec file changes
+ improve descriptions
+ add man pages
* Wed Sep 20 2017 buschmann23@opensuse.org
- spec file changes
+ improve package description
* Fri Jun 23 2017 buschmann23@opensuse.org
- update to Brotli 0.6.0
+ better compression on 1MiB+ files
+ update "common" API to make dictionary fetching more flexible
+ fix decoder bug #502
+ faster compression on mid-low quality levels
+ fix encoder q10-11 slowdown after long copy #468
+ introduce Brotli*TakeOutput API
- now build shared libraries and development files in the following
new packages:
+ libbrotlicommon0_6_0
+ libbrotlicommon-devel
+ libbrotlidec0_6_0
+ libbrotlidec-devel
+ libbrotlienc0_6_0
+ libbrtolienc-devel
* Fri Mar 24 2017 buschmann23@opensuse.org
- initial package

143
brotli.spec Normal file
View file

@ -0,0 +1,143 @@
#
# spec file for package brotli
#
# Copyright (c) 2022-2023 ZhuningOS
#
#
%define sover 1
Name: brotli
Version: 1.0.7
Release: 3.3.1
Summary: Lossless Compression Algorithm
License: MIT
Group: Productivity/Archiving/Compression
URL: https://github.com/google/brotli
Source: %url/archive/v%version.tar.gz#/%name-%version.tar.gz
Source99: baselibs.conf
Patch: brotli_Verbose-CLI+Shared-Brotli.patch
Patch1: brotli_Ensure-decompression-consumes-all-input.patch
# PATCH-FIX-UPSTREAM fix-cve-2020-8927.patch bsc#1175825
Patch2: fix-cve-2020-8927.patch
BuildRequires: cmake >= 2.8.6
BuildRequires: gcc-c++
BuildRequires: gzip
BuildRequires: pkg-config
%description
This package contains the brotli command line utility to compress and
decompress data with the brotli compression algorithm.
Brotli is a generic-purpose lossless compression algorithm that
compresses data using a combination of a modern variant of the LZ77
algorithm, Huffman coding and 2nd order context modeling, with a
compression ratio comparable to the best currently available
general-purpose compression methods. It is similar in speed with
deflate but offers more dense compression.
The specification of the Brotli Compressed Data Format is defined in
RFC 7932.
%package -n libbrotlicommon%sover
Summary: Common Library for Brotli Compression
Group: System/Libraries
%description -n libbrotlicommon%sover
Common library for the Brotli general purpose lossless data
compression algorithm.
%package -n libbrotlidec%sover
Summary: Library for Brotli Decompression
Group: System/Libraries
%description -n libbrotlidec%sover
Decompression library for the Brotli general purpose lossless data
compression algorithm.
The specification of the Brotli Compressed Data Format is defined in
RFC 7932.
%package -n libbrotlienc%sover
Summary: Library for Brotli Compression
Group: System/Libraries
%description -n libbrotlienc%sover
Compression library for the Brotli general purpose lossless data
compression algorithm.
The specification of the Brotli Compressed Data Format is defined in
RFC 7932.
%package -n libbrotli-devel
Summary: Development and Header Files for Brotli Compression
Group: Development/Libraries/C and C++
Requires: libbrotlicommon%sover = %version-%release
Requires: libbrotlidec%sover = %version-%release
Requires: libbrotlienc%sover = %version-%release
Provides: libbrotlicommon-devel = %version-%release
Provides: libbrotlidec-devel = %version-%release
Provides: libbrotlienc-devel = %version-%release
Obsoletes: libbrotlicommon-devel < %version-%release
Obsoletes: libbrotlidec-devel < %version-%release
Obsoletes: libbrotlienc-devel < %version-%release
%description -n libbrotli-devel
Development and headers files for (de)compressing data using the
Brotli general purpose lossless compression algorithm.
The specification of the Brotli Compressed Data Format is defined in
RFC 7932.
%prep
%autosetup -p1
%build
%cmake
%make_jobs
%install
%cmake_install
rm %buildroot/%_libdir/libbrotli*-static.a
mkdir -p "%buildroot/%_mandir/man1" "%buildroot/%_mandir/man3"
install -pm0644 docs/*.1 "%buildroot/%_mandir/man1/"
install -pm0644 docs/*.3 "%buildroot/%_mandir/man3/"
%check
%ctest
%post -n libbrotlicommon%sover -p /sbin/ldconfig
%postun -n libbrotlicommon%sover -p /sbin/ldconfig
%post -n libbrotlidec%sover -p /sbin/ldconfig
%postun -n libbrotlidec%sover -p /sbin/ldconfig
%post -n libbrotlienc%sover -p /sbin/ldconfig
%postun -n libbrotlienc%sover -p /sbin/ldconfig
%files
%defattr(-,root,root)
%license LICENSE
%_bindir/brotli
%_mandir/man1/brotli.1*
%files -n libbrotlicommon%sover
%defattr(-,root,root)
%_libdir/libbrotlicommon.so.*
%files -n libbrotlidec%sover
%defattr(-,root,root)
%_libdir/libbrotlidec.so.*
%files -n libbrotlienc%sover
%defattr(-,root,root)
%_libdir/libbrotlienc.so.*
%files -n libbrotli-devel
%defattr(-,root,root)
%_includedir/brotli/
%_libdir/libbrotlicommon.so
%_libdir/libbrotlidec.so
%_libdir/libbrotlienc.so
%_libdir/pkgconfig/*.pc
%_mandir/man3/*.3*
%changelog

View file

@ -0,0 +1,74 @@
From 5805f99a533a8f8118699c0100d8c102f3605f65 Mon Sep 17 00:00:00 2001
From: Justin Ridgewell <justin@ridgewell.name>
Date: Mon, 12 Nov 2018 04:36:00 -0500
Subject: [PATCH] Ensure decompression consumes all input (#730)
* Ensure decompression consumes all input
If not, it's a corrupt stream.
* Use byte strings
---
python/_brotli.cc | 4 ++--
python/tests/decompress_test.py | 4 ++++
python/tests/decompressor_test.py | 9 +++++++++
3 files changed, 15 insertions(+), 2 deletions(-)
diff --git a/python/_brotli.cc b/python/_brotli.cc
index a6f925ef..5e1828e9 100644
--- a/python/_brotli.cc
+++ b/python/_brotli.cc
@@ -414,7 +414,7 @@ static BROTLI_BOOL decompress_stream(BrotliDecoderState* dec,
(*output).insert((*output).end(), buffer, buffer + buffer_length);
}
}
- ok = result != BROTLI_DECODER_RESULT_ERROR;
+ ok = result != BROTLI_DECODER_RESULT_ERROR && !available_in;
Py_END_ALLOW_THREADS
return ok;
@@ -672,7 +672,7 @@ static PyObject* brotli_decompress(PyObject *self, PyObject *args, PyObject *key
if (available_out != 0)
output.insert(output.end(), next_out, next_out + available_out);
}
- ok = result == BROTLI_DECODER_RESULT_SUCCESS;
+ ok = result == BROTLI_DECODER_RESULT_SUCCESS && !available_in;
BrotliDecoderDestroyInstance(state);
Py_END_ALLOW_THREADS
diff --git a/python/tests/decompress_test.py b/python/tests/decompress_test.py
index 7a9e9e30..814e5633 100644
--- a/python/tests/decompress_test.py
+++ b/python/tests/decompress_test.py
@@ -31,6 +31,10 @@ def _test_decompress(self, test_data):
self._decompress(test_data)
self._check_decompression(test_data)
+ def test_garbage_appended(self):
+ with self.assertRaises(brotli.error):
+ brotli.decompress(brotli.compress(b'a') + b'a')
+
_test_utils.generate_test_methods(TestDecompress, for_decompression=True)
diff --git a/python/tests/decompressor_test.py b/python/tests/decompressor_test.py
index 99667bcd..05918ada 100644
--- a/python/tests/decompressor_test.py
+++ b/python/tests/decompressor_test.py
@@ -43,6 +43,15 @@ def _test_decompress(self, test_data):
self._decompress(test_data)
self._check_decompression(test_data)
+ def test_garbage_appended(self):
+ with self.assertRaises(brotli.error):
+ self.decompressor.process(brotli.compress(b'a') + b'a')
+
+ def test_already_finished(self):
+ self.decompressor.process(brotli.compress(b'a'))
+ with self.assertRaises(brotli.error):
+ self.decompressor.process(b'a')
+
_test_utils.generate_test_methods(TestDecompressor, for_decompression=True)

File diff suppressed because it is too large Load diff

1212
fix-cve-2020-8927.patch Normal file

File diff suppressed because it is too large Load diff