Skip to content

Commit d69d461

Browse files
Test: Fuzztest for ConfirmMessageIterator (#1605)
Signed-off-by: Jake Jendzurski <jakeski2015@gmail.com> Signed-off-by: Patrick M. Niedzielski <pniedzielski@bloomberg.net> Co-authored-by: Patrick M. Niedzielski <pniedzielski@bloomberg.net>
1 parent 3f23550 commit d69d461

2 files changed

Lines changed: 56 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_confirmmessageiterator.fuzz
23
s_bmqfuzz_bmqp_crc32c.fuzz
34
s_bmqfuzz_bmqp_event_initialize.fuzz
45
s_bmqfuzz_bmqp_pushmessageiterator.fuzz
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
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 <bslma_default.h>
20+
21+
#include <bmqp_confirmmessageiterator.h>
22+
#include <bmqp_protocol.h>
23+
24+
using namespace BloombergLP;
25+
26+
extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size)
27+
{
28+
if (size < sizeof(bmqp::EventHeader)) {
29+
return 0;
30+
}
31+
32+
bslma::Allocator* alloc = bslma::Default::defaultAllocator();
33+
bdlbb::PooledBlobBufferFactory bufferFactory(1024, alloc);
34+
35+
bdlbb::Blob blob(&bufferFactory, alloc);
36+
bdlbb::BlobUtil::append(&blob,
37+
reinterpret_cast<const char*>(data),
38+
static_cast<int>(size));
39+
40+
bmqp::EventHeader eventHeader;
41+
bsl::memcpy(&eventHeader, data, sizeof(bmqp::EventHeader));
42+
43+
bmqp::ConfirmMessageIterator iter;
44+
int rc = iter.reset(&blob, eventHeader);
45+
if (rc != 0) {
46+
return 0;
47+
}
48+
49+
while (iter.next() == 1) {
50+
iter.header();
51+
iter.message();
52+
}
53+
54+
return 0;
55+
}

0 commit comments

Comments
 (0)