Skip to content

Commit 281026d

Browse files
committed
added compression::decompress fuzztest
Signed-off-by: Jake Jendzurski <jakeski2015@gmail.com>
1 parent 5d2e957 commit 281026d

2 files changed

Lines changed: 53 additions & 0 deletions

File tree

src/standalones/s_bmqfuzz/package/s_bmqfuzz.mem

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
s_bmqfuzz_bmqp_ackmessageiterator.fuzz
2+
s_bmqfuzz_bmqp_compression_decompress.fuzz
23
s_bmqfuzz_bmqp_confirmmessageiterator.fuzz
34
s_bmqfuzz_bmqp_crc32c.fuzz
45
s_bmqfuzz_bmqp_event_initialize.fuzz
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
// Copyright 2026 Bloomberg Finance L.P.
2+
// SPDX-License-Identifier: Apache-2.0
3+
//
4+
// Licensed under the Apache License, Version 2.0 (the "License");
5+
// you may not use this file except in compliance with the License.
6+
// You may obtain a copy of the License at
7+
//
8+
// http://www.apache.org/licenses/LICENSE-2.0
9+
//
10+
// Unless required by applicable law or agreed to in writing, software
11+
// distributed under the License is distributed on an "AS IS" BASIS,
12+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
// See the License for the specific language governing permissions and
14+
// limitations under the License.
15+
16+
#include <bdlbb_blob.h>
17+
#include <bdlbb_blobutil.h>
18+
#include <bdlbb_pooledblobbufferfactory.h>
19+
#include <bsl_limits.h>
20+
#include <bsl_sstream.h>
21+
#include <bslma_default.h>
22+
23+
#include <bmqp_compression.h>
24+
#include <bmqt_compressionalgorithmtype.h>
25+
26+
using namespace BloombergLP;
27+
28+
extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size)
29+
{
30+
if (size > bsl::numeric_limits<int>::max()) {
31+
return 0;
32+
}
33+
34+
bslma::Allocator* alloc = bslma::Default::defaultAllocator();
35+
bdlbb::PooledBlobBufferFactory bufferFactory(1024, alloc);
36+
37+
bdlbb::Blob input(&bufferFactory, alloc);
38+
bdlbb::BlobUtil::append(&input,
39+
reinterpret_cast<const char*>(data),
40+
static_cast<int>(size));
41+
42+
bdlbb::Blob output(&bufferFactory, alloc);
43+
bsl::ostringstream errorStream(alloc);
44+
bmqp::Compression::decompress(&output,
45+
&bufferFactory,
46+
bmqt::CompressionAlgorithmType::e_ZLIB,
47+
input,
48+
&errorStream,
49+
alloc);
50+
51+
return 0;
52+
}

0 commit comments

Comments
 (0)