|
| 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