Skip to content

Commit 3e4d2ba

Browse files
Test: Fuzztest for MessageProperties::streamIn() (#1604)
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 200760b commit 3e4d2ba

2 files changed

Lines changed: 54 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
@@ -2,6 +2,7 @@ s_bmqfuzz_bmqp_ackmessageiterator.fuzz
22
s_bmqfuzz_bmqp_confirmmessageiterator.fuzz
33
s_bmqfuzz_bmqp_crc32c.fuzz
44
s_bmqfuzz_bmqp_event_initialize.fuzz
5+
s_bmqfuzz_bmqp_messageproperties_streamin.fuzz
56
s_bmqfuzz_bmqp_pushmessageiterator.fuzz
67
s_bmqfuzz_bmqp_putmessageiterator.fuzz
78
s_bmqfuzz_bmqp_recoverymessageiterator.fuzz
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
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_messageproperties.h>
22+
23+
using namespace BloombergLP;
24+
25+
extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size)
26+
{
27+
if (size < sizeof(bmqp::MessagePropertiesHeader) + 1) {
28+
return 0;
29+
}
30+
31+
bool isNewStyle = (data[0] & 1);
32+
data++;
33+
size--;
34+
35+
bslma::Allocator* alloc = bslma::Default::defaultAllocator();
36+
bdlbb::PooledBlobBufferFactory bufferFactory(1024, alloc);
37+
38+
bdlbb::Blob blob(&bufferFactory, alloc);
39+
bdlbb::BlobUtil::append(&blob,
40+
reinterpret_cast<const char*>(data),
41+
static_cast<int>(size));
42+
43+
bmqp::MessageProperties props(alloc);
44+
int rc = props.streamIn(blob, isNewStyle);
45+
if (rc != 0) {
46+
return 0;
47+
}
48+
49+
props.numProperties();
50+
props.totalSize();
51+
52+
return 0;
53+
}

0 commit comments

Comments
 (0)